Skip to content

Commit a232747

Browse files
committed
Add qemu example for running alsa
Signed-off-by: Anders F Björklund <[email protected]>
1 parent 22dcd62 commit a232747

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Optional feature enablers:
5656
- [`experimental/net-user-v2`](./experimental/net-user-v2.yaml): [experimental] user-v2 network
5757
to enable VM-to-VM communication without root privilege
5858
- [`experimental/vnc`](./experimental/vnc.yaml): [experimental] use vnc display and xorg server
59+
- [`experimental/alsa`](./experimental/alsa.yaml): [experimental] use alsa and default audio device
5960

6061
Lost+found:
6162
- ~`centos`~: Removed in Lima v0.8.0, as CentOS 8 reached [EOL](https://www.centos.org/centos-linux-eol/).

examples/experimental/alsa.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# A template to run ubuntu using device: default
2+
# This template requires Lima v0.23.0 or later.
3+
images:
4+
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
5+
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240423/ubuntu-24.04-server-cloudimg-amd64.img"
6+
arch: "x86_64"
7+
digest: "sha256:32a9d30d18803da72f5936cf2b7b9efcb4d0bb63c67933f17e3bdfd1751de3f3"
8+
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240423/ubuntu-24.04-server-cloudimg-arm64.img"
9+
arch: "aarch64"
10+
digest: "sha256:c841bac00925d3e6892d979798103a867931f255f28fefd9d5e07e3e22d0ef22"
11+
# Fallback to the latest release image.
12+
# Hint: run `limactl prune` to invalidate the cache
13+
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
14+
arch: "x86_64"
15+
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img"
16+
arch: "aarch64"
17+
18+
mounts:
19+
- location: "~"
20+
- location: "/tmp/lima"
21+
writable: true
22+
23+
vmType: "qemu"
24+
audio:
25+
device: "default"
26+
27+
provision:
28+
- mode: system
29+
script: |
30+
#!/bin/bash
31+
set -eux -o pipefail
32+
test -e /lib/modules/$(uname -r)/kernel/sound/pci/hda/snd-hda-intel.ko* && exit 0
33+
apt-get install -y linux-modules-extra-$(uname -r)
34+
modprobe snd-hda-intel
35+
- mode: system
36+
script: |
37+
#!/bin/bash
38+
set -eux -o pipefail
39+
command -v aplay >/dev/null 2>&1 && exit 0
40+
apt-get install -y --no-install-recommends alsa-utils
41+
probes:
42+
- description: "alsa to be installed"
43+
script: |
44+
#!/bin/bash
45+
set -eux -o pipefail
46+
if ! timeout 30s bash -c "until command -v aplay >/dev/null 2>&1; do sleep 3; done"; then
47+
echo >&2 "alsa is not installed yet"
48+
exit 1
49+
fi
50+
hint: See "/var/log/cloud-init-output.log" in the guest
51+
message: |
52+
To get a list of all available audio devices:
53+
$ sudo aplay -L
54+
To test the audio device, use something like:
55+
$ sudo speaker-test -c2 -twav

0 commit comments

Comments
 (0)