SVM loading with VIRTIO-SND
-
When launching the Secondary Virtual Machine (SVM) using Crosvm, I encounter the message "No soundcards found" despite having recompiled the Linux kernel (Image) with the CONFIG_SND_VIRTIO=y flag enabled. Does Crosvm lack support for VirtIO sound, or are additional backend configurations required in the Primary Virtual Machine (PVM) to enable VirtIO sound?
-
Instead of Crosvm, can I use Libvirt/Virt-install in the PVM to create and launch the SVM? If yes, would I need to install Libvirt/Virt-install on the PVM? Note that the PVM does not support installing packages via apt.
- When launching the Secondary Virtual Machine (SVM) using Crosvm, I encounter the message "No soundcards found" despite having recompiled the Linux kernel (Image) with the CONFIG_SND_VIRTIO=y flag enabled. Does Crosvm lack support for VirtIO sound, or are additional backend configurations required in the Primary Virtual Machine (PVM) to enable VirtIO sound?
I haven't tried using virtio-snd, but it seems like it should be supported with crosvm:
https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/virtio/snd/
- Instead of Crosvm, can I use Libvirt/Virt-install in the PVM to create and launch the SVM? If yes, would I need to install Libvirt/Virt-install on the PVM? Note that the PVM does not support installing packages via apt.
We haven't started any efforts yet to add support for Gunyah in libvirt/virt-install.
We have sent a couple RFCs for QEMU, although we'd have to check with Srivatsa about how functional it is with these patches: https://lore.kernel.org/all/[email protected]/
- When launching the Secondary Virtual Machine (SVM) using Crosvm, I encounter the message "No soundcards found" despite having recompiled the Linux kernel (Image) with the CONFIG_SND_VIRTIO=y flag enabled. Does Crosvm lack support for VirtIO sound, or are additional backend configurations required in the Primary Virtual Machine (PVM) to enable VirtIO sound?
I was able to boot a VM with a virtual sound device via crosvm with the above steps. [ 0.360628][ T1] ALSA device list: [ 0.360748][ T1] #0: VirtIO SoundCard at pci/0000:00:02.0/virtio1
Can you confirm if the CONFIG_SND_VIRTIO was indeed enabled in the VM image you are using? Also, could you please provide the command you are using to launch the VM via crosvm with virtio-snd?
@quic-pheragu
When I'm trying to boot up PVM using VM Image (CONFIG_SND_VIRTIO enabled), then I can see: [ 2.963037] ALSA device list: [ 2.963686] #0: VirtIO SoundCard at pci/0000:00:02.0/virtio1
But within the PVM, while booting up GVM I'm using the same VM Image( which I used to boot up PVM) , then I can see: [ 24.952272] ALSA device list: [ 24.965106] No soundcards found.
The crosvm command I'm using:
/usr/gunyah/crosvm --no-syslog run --disable-sandbox \
--serial=type=stdout,hardware=virtio-console,console,stdin,num=1 \
--serial=type=stdout,hardware=serial,earlycon,num=1 \
--initrd /usr/gunyah/initrd.img --no-rng \
--params "rw root=/dev/ram rdinit=/sbin/init earlyprintk=serial panic=0" \
/usr/gunyah/Image
I also tried to execute:
/usr/gunyah/crosvm --no-syslog run --disable-sandbox \
--serial=type=stdout,hardware=virtio-console,console,stdin,num=1 \
--serial=type=stdout,hardware=serial,earlycon,num=1 \
--initrd /usr/gunyah/initrd.img --no-rng \
--params "rw root=/dev/ram rdinit=/sbin/init earlyprintk=serial panic=0" \
--device virtio-sound-pci,audiodev=my_audiodev \
--audiodev alsa,id=my_audiodev \
/usr/gunyah/Image
but crosvm doesn't support --device argument
[2024-06-06T04:49:29.240714080+00:00 ERROR crosvm] arg parsing failed: Unrecognized argument: --device
[2024-06-06T04:49:29.253384944+00:00 INFO crosvm] invalid argument
Also, can we boot up Comprehensive Linux OS in GVM? So that can play audio files (aplay tool) in GVM using aplay tools.
Thanks
@quic-pheragu
When I'm trying to boot up PVM using VM Image (CONFIG_SND_VIRTIO enabled), then I can see: [ 2.963037] ALSA device list: [ 2.963686] #0: VirtIO SoundCard at pci/0000:00:02.0/virtio1
But within the PVM, while booting up GVM I'm using the same VM Image( which I used to boot up PVM) , then I can see: [ 24.952272] ALSA device list: [ 24.965106] No soundcards found.
The crosvm command I'm using:
/usr/gunyah/crosvm --no-syslog run --disable-sandbox \ --serial=type=stdout,hardware=virtio-console,console,stdin,num=1 \ --serial=type=stdout,hardware=serial,earlycon,num=1 \ --initrd /usr/gunyah/initrd.img --no-rng \ --params "rw root=/dev/ram rdinit=/sbin/init earlyprintk=serial panic=0" \ /usr/gunyah/ImageI also tried to execute:
/usr/gunyah/crosvm --no-syslog run --disable-sandbox \ --serial=type=stdout,hardware=virtio-console,console,stdin,num=1 \ --serial=type=stdout,hardware=serial,earlycon,num=1 \ --initrd /usr/gunyah/initrd.img --no-rng \ --params "rw root=/dev/ram rdinit=/sbin/init earlyprintk=serial panic=0" \ --device virtio-sound-pci,audiodev=my_audiodev \ --audiodev alsa,id=my_audiodev \ /usr/gunyah/Imagebut crosvm doesn't support --device argument
[2024-06-06T04:49:29.240714080+00:00 ERROR crosvm] arg parsing failed: Unrecognized argument: --device [2024-06-06T04:49:29.253384944+00:00 INFO crosvm] invalid argument
/usr/gunyah/crosvm --no-syslog run --disable-sandbox --hypervisor gunyah --serial=type=stdout,hardware=virtio-console,console,stdin,num=1 --serial=type=stdout,hardware=serial,earlycon,num=1 --initrd /data/gunyah/initrd.img --hugepages --no-balloon --no-rng --protected-vm-without-firmware --swiotlb 10 --virtio-snd backend=file,playback_path=/data/gunyah,playback_size=400000 --params "rw root=/dev/ram rdinit=/sbin/init\
Can you try using this command with virtio-snd arg instead?
Also, can we boot up Comprehensive Linux OS in GVM? So that can play audio files (aplay tool) in GVM using aplay tools.
With limited memory, I don't think you will be able to boot a full blown linux as a secondary VM.
Thanks
Best Regards!
@quic-pheragu
Thanks for your quick reply!!
/usr/gunyah/crosvm --no-syslog run --disable-sandbox --hypervisor gunyah --serial=type=stdout,hardware=virtio-console,console,stdin,num=1 --serial=type=stdout,hardware=serial,earlycon,num=1 --initrd /data/gunyah/initrd.img --hugepages --no-balloon --no-rng --protected-vm-without-firmware --swiotlb 10 --virtio-snd backend=file,playback_path=/data/gunyah,playback_size=400000 --params "rw root=/dev/ram rdinit=/sbin/init\
Can you try using this command with virtio-snd arg instead?
Three doubts:
- in your command, I cannot see the kernel image (Image)
- --no-balloon arg is not supported
[2024-06-08T05:25:28.796012240+00:00 ERROR crosvm] arg parsing failed: Unrecognized argument: --no-balloon - --virtio-snd arg is not supported
root@qemuarm64:/usr/gunyah# /usr/gunyah/crosvm --no-syslog run --disable-sandbox \
> --hypervisor gunyah \
> --serial=type=stdout,hardware=virtio-console,console,stdin,num=1 \
> --serial=type=stdout,hardware=serial,earlycon,num=1 \
> --initrd ./initrd.img --hugepages --no-rng \
> --protected-vm-without-firmware --swiotlb 10 \
> --params "rw root=/dev/ram rdinit=/sbin/init earlyprintk=serial panic=0" \
> --virtio-snd backend=file,playback_path=/data/gunyah,playback_size=400000 \
> /usr/gunyah/Image
[2024-06-08T05:27:02.268950848+00:00 ERROR crosvm] arg parsing failed: Unrecognized argument: --virtio-snd
[2024-06-08T05:27:02.271552640+00:00 INFO crosvm] invalid argument
I don't know why --no-balloon and --virtio-snd is not supports here. Is it the crosvm version issue? For me it is crosvm 0.1.0
I followed the scripts (clone and build_crosvm.sh) to build and install crosvm.
But when I tried to build and run crosvm on my host (for x86_64), --virtio-snd arg supports.
I'm curious now, whether --virtio-snd arg is not supported for aarch64?
Best Regards!
Is it the crosvm version issue? For me it is crosvm 0.1.0
FYI -- crosvm devs don't update the version, it's been 0.1.0 since 2017. We'd be compiling from a decently recent source version of crosvm. Source SHA from chromium's repo would be best point of comparison.
The build_crosvm.sh in the support scripts is just enough to demo the existence of Gunyah virtual machines; you probably will want to adjust the build command to add additional features to the VMM. Notably, there's --no-default-features in that build command, which disables audio and balloon support.
Hi, now host is linux and use alsa,guest is linux too,How do I configure crosvm and --virtio-snd so I can play directly in the guest side?
Hi,The sound card information on the host is /dev/snd/pcmC0D0p.How do I configure crosvm and --virtio-snd?
Hi,The sound card information on the host is /dev/snd/pcmC0D0p.How do I configure crosvm and --virtio-snd?
I quickly tried passing --virtio-snd playback_path=/dev/snd/pcmC0D0p,playback_size=400000 to the crosvm cmd. It seems to enumerate a Soundcard on the VM [ 0.341903][ T1] ALSA device list: [ 0.342056][ T1] #0: VirtIO SoundCard at pci/0000:00:02.0/virtio1
Can you try your experiment with this?
您好,您的邮件我已经收到!谢谢!
Hi , 1、My host environment is as follows: root@ubuntu:/# ls /dev/snd/pcmC0D0p /dev/snd/pcmC0D0p root@ubuntu:/# cat /proc/asound/cards 0 [rockchipes8388 ]: rockchip-es8388 - rockchip-es8388 rockchip-es8388 2、And my croswm cmd as below: --virtio-snd playback_path=/dev/snd/pcmC0D0p,playback_size=400000
3、my guest side as below: root@ubuntu:/home/rockchip# ls /dev/snd/ by-path controlC0 pcmC0D0c pcmC0D0p timer
4、When I play music in the guest side: aplay sn.wav, there is no sound, but I play it directly in the host side is normal。
When I play music in the guest side: aplay sn.wav, the sound card in the host side is turned off
Is it the crosvm version issue? For me it is crosvm 0.1.0
FYI -- crosvm devs don't update the version, it's been 0.1.0 since 2017. We'd be compiling from a decently recent source version of crosvm. Source SHA from chromium's repo would be best point of comparison.
The build_crosvm.sh in the support scripts is just enough to demo the existence of Gunyah virtual machines; you probably will want to adjust the build command to add additional features to the VMM. Notably, there's
--no-default-featuresin that build command, which disables audio and balloon support.
Yes @eberman-quic , You was right. Because --no-default-features was used while building crosvm, audio and balloon support was disabled.
Additionally, crosvm will require shared libraries: libwayland-client and libffi. To get it, did some modifications in build-rootfs-img.sh
I used below command to up GVM using crosvm:
/usr/gunyah/crosvm --no-syslog run --disable-sandbox \
--hypervisor gunyah \
--serial=type=stdout,hardware=virtio-console,console,stdin,num=1 \
--serial=type=stdout,hardware=serial,earlycon,num=1 \
--initrd /usr/gunyah/initrd.img --hugepages --no-balloon --no-rng \
--virtio-snd backend=file,playback_path=/data/gunyah,playback_size=400000 \
--params "rw root=/dev/ram rdinit=/sbin/init earlyprintk=serial panic=0" \
/usr/gunyah/Image
Thanks and Best Regards!!
When I play music in the guest side: aplay sn.wav, the sound card in the host side is turned off
There could be some input parameters to CrosVM that might have to be tweaked. I am not very familiar with that. Could you please ask this directly on the CrosVM mailing list?
When I play music in the guest side: aplay sn.wav, the sound card in the host side is turned off
Hi @chenshiqin, are you using aplay tool in PVM or in GVM? If yes, how you managed it to install it on these VMs? Note: I'm using the Linux kernel image which is generated by scripts provided in repository.