Skip to content

Commit

Permalink
Add qemu example for running alsa
Browse files Browse the repository at this point in the history
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
  • Loading branch information
afbjorklund committed Jul 2, 2024
1 parent f6ea584 commit c365809
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Optional feature enablers:
- [`experimental/net-user-v2`](./experimental/net-user-v2.yaml): [experimental] user-v2 network
to enable VM-to-VM communication without root privilege
- [`experimental/vnc`](./experimental/vnc.yaml): [experimental] use vnc display and xorg server
- [`experimental/alsa`](./experimental/alsa.yaml): [experimental] use alsa and default audio device

Lost+found:
- ~`centos`~: Removed in Lima v0.8.0, as CentOS 8 reached [EOL](https://www.centos.org/centos-linux-eol/).
Expand Down
55 changes: 55 additions & 0 deletions examples/experimental/alsa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# A template to run ubuntu using audio: default
# This template requires Lima v0.23.0 or later.
images:
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240423/ubuntu-24.04-server-cloudimg-amd64.img"
arch: "x86_64"
digest: "sha256:32a9d30d18803da72f5936cf2b7b9efcb4d0bb63c67933f17e3bdfd1751de3f3"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240423/ubuntu-24.04-server-cloudimg-arm64.img"
arch: "aarch64"
digest: "sha256:c841bac00925d3e6892d979798103a867931f255f28fefd9d5e07e3e22d0ef22"
# Fallback to the latest release image.
# Hint: run `limactl prune` to invalidate the cache
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img"
arch: "aarch64"

mounts:
- location: "~"
- location: "/tmp/lima"
writable: true

vmType: "qemu"
audio:
device: "default"

provision:
- mode: system
script: |
#!/bin/bash
set -eux -o pipefail
test -e /lib/modules/$(uname -r)/kernel/sound/pci/hda/snd-hda-intel.ko* && exit 0
apt-get install -y linux-modules-extra-$(uname -r)
modprobe snd-hda-intel
- mode: system
script: |
#!/bin/bash
set -eux -o pipefail
command -v aplay >/dev/null 2>&1 && exit 0
apt-get install -y --no-install-recommends alsa-utils
probes:
- description: "alsa to be installed"
script: |
#!/bin/bash
set -eux -o pipefail
if ! timeout 30s bash -c "until command -v aplay >/dev/null 2>&1; do sleep 3; done"; then
echo >&2 "alsa is not installed yet"
exit 1
fi
hint: See "/var/log/cloud-init-output.log". in the guest
message: |
To get a list of all available audio devices:
$ sudo aplay -L
To test the audio device, use something like:
$ sudo speaker-test -c2 -twav

0 comments on commit c365809

Please sign in to comment.