Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVM loading with VIRTIO-SND #27

Open
aniantre opened this issue May 31, 2024 · 15 comments
Open

SVM loading with VIRTIO-SND #27

aniantre opened this issue May 31, 2024 · 15 comments

Comments

@aniantre
Copy link

  1. 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?

  2. 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.

@eberman-quic
Copy link

  1. 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/

  1. 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]/

@quic-pheragu
Copy link

  1. 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?

@aniantre
Copy link
Author

aniantre commented Jun 6, 2024

@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
Copy link

@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

/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!

@aniantre
Copy link
Author

aniantre commented Jun 8, 2024

@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:

  1. in your command, I cannot see the kernel image (Image)
  2. --no-balloon arg is not supported
    [2024-06-08T05:25:28.796012240+00:00 ERROR crosvm] arg parsing failed: Unrecognized argument: --no-balloon
  3. --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!

@eberman-quic
Copy link

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.

@chenshiqin
Copy link

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?

@chenshiqin
Copy link

Hi,The sound card information on the host is /dev/snd/pcmC0D0p.How do I configure crosvm and --virtio-snd?

@quic-pheragu
Copy link

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?

@chenshiqin
Copy link

chenshiqin commented Jun 12, 2024 via email

@chenshiqin
Copy link

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。

@chenshiqin
Copy link

When I play music in the guest side: aplay sn.wav, the sound card in the host side is turned off

@aniantre
Copy link
Author

aniantre commented Jun 13, 2024

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.

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!!

@quic-pheragu
Copy link

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?

@aniantre
Copy link
Author

aniantre commented Jun 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants