Seeking feedback: qemu-virgl, fully 3D accelerated qemu

I just release the first package of qemu-virgl which is a build of the latest QEMU git version (see https://www.qemu.org/) with ebaled SDL2 and GTK3 support by default. The package is also built against the last virglrenderer library from https://virgil3d.github.io/ to provide full 3D acceleration inside the VM.

I was able to test on intel and nvidia systems but due to lacking a recent amdgpu based machine I could not test in such an environment. I would appreciate if someone with such hardware could give it a spin and give some feedback here.

To install it:

sudo snap install qemu-virgil

Manually connect the kvm interface:

sudo snap connect qemu-virgil:kvm

Download an ubuntu-core image:
http://cdimage.ubuntu.com/ubuntu-core/16/edge/current/ubuntu-core-16-amd64.img.xz

and unxz it …

Then you can run a vm like:

qemu-virgil -enable-kvm -m 1024 -device virtio-vga,virgl=on -display sdl,gl=on -redir tcp:10022::22 ubuntu-core-16-amd64.img

This shoudl spin up a core VM … run through the configuration and then you can talk to the system via ssh:

ssh -p 10022 localhost

To check if virgl is working:

dmesg|grep virgl
[    2.411299] [drm] virgl 3d acceleration enabled

If that works you can i.e. install mir-kiosk and mir-kiosk-apps --beta to actually make use of the accelerated graphics.
(do not forget to “snap connect mir-kiosk-apps:wayland-socket-dir mir-kiosk:wayland-socket-dir”, else the apps will not start)

1 Like

Hi Oliver,

just one question, I’m using qemu-virgil with android-x86 in order to test gralloc stacks,
is there a way to setup qemu-virgil in virt-manager, I could not find the option to set the virtio-vga with 3D acceleration.
Thanks for your feedback

Mauro Rossi
android-x86 team

1 Like

I don’t use libvirt/virt-manager a lot, what are the exact symptoms you see, what have you tried yet to make it work …

there is a newer qemu-virgil in the edge channel too that i havent been able to fully test yet, you could try switching to it.

snap refresh --edge qemu-virgil

(to switch back to stable just replace —edge with --stable in the above command)

Hi, many thanks for quick answer
I tried the edge version 3.0.91, but it gives me error:

qemu-virgil -enable-kvm \

-m 2048 -device virtio-vga,virgl=on -display sdl,gl=on -soundhw ac97
-cdrom /home/utente/Downloads/android-x86_64-8.1-rc2.iso
qemu-system-x86_64: error: failed to set MSR 0x10a to 0x0
qemu-system-x86_64: /build/qemu-virgil/parts/qemu/build/target/i386/kvm.c:2211: kvm_put_msrs: Assertion `ret == cpu->kvm_msr_buf->nmsrs’ failed.
Aborted (core dumped)

The problem with libvirt/virt-manager is not in qemu-virgl, of course, I was just seeking for help and for a confirmation that libvirt/virt-manager is lacking essential feature.

The symptoms are that running with commandline 3D acceleration is available and qemu automatically switches to graphical display at bootanimation Android logo

qemu-virgil -enable-kvm
-m 2048 -device virtio-vga,virgl=on -display sdl,gl=on -soundhw ac97
-cdrom ~/oreo-x86/out/target/product/x86_64/android_x86_64.iso
[Result: booting ok]

Using virt-manager the 3D acceleration option in the Details -> “Video virtio”, I get an error:

Error starting domain: unsupported configuration: virtio 3d acceleration is not supported

Traceback (most recent call last):
File “/usr/share/virt-manager/virtManager/asyncjob.py”, line 89, in cb_wrapper
callback(asyncjob, *args, **kwargs)
File “/usr/share/virt-manager/virtManager/asyncjob.py”, line 125, in tmpcb
callback(*args, **kwargs)
File “/usr/share/virt-manager/virtManager/libvirtobject.py”, line 82, in newfn
ret = fn(self, *args, **kwargs)
File “/usr/share/virt-manager/virtManager/domain.py”, line 1508, in startup
self._backend.create()
File “/usr/lib/python2.7/dist-packages/libvirt.py”, line 1080, in create
if ret == -1: raise libvirtError (‘virDomainCreate() failed’, dom=self)
libvirtError: unsupported configuration: virtio 3d acceleration is not supported

libvirt mantainers should do the changes to make virtio_gpu work, it does not make sense not to exploit the 3D acceleration, but you already know that, because you cared about qemu-virgil in the first place.

Mauro

The crash in 3.0.91 is due to this bug:

https://bugzilla.redhat.com/show_bug.cgi?id=1655826

Cheers
Mauro

1 Like

Awesome, thanks, i’ll make sure to have the fix for that in the snap (seems to already be in master) before next edge gets released to stable …

$ qemu-virgil -enable-kvm -m 1024 -device virtio-vga,virgl=on -display sdl,gl=on -redir tcp:10022::22 ubuntu-core-16-amd64.img
qemu-system-x86_64: -redir tcp:10022::22: The -redir option is deprecated. Please use '-netdev user,hostfwd=...' instead.
Could not access KVM kernel module: Permission denied
qemu-system-x86_64: failed to initialize KVM: Permission denied

looks like you didnt connect the kvm interface …
(see snap info for qemu-virgil … )

1 Like

I did, it’s connected.

:kvm qemu-virgil

1 Like

wow, this is weird then … you arent trying to run it on core i guess ?

Nope, I’m trying this on my 18.04 laptop / desktop I use all day.

1 Like

the edge channel should now have 3.1.50 with the fix for this bug …

smells like the udev rules have changed in 18.04, normally udev-acl should provide you access (perhaps @jdstrand could shed some light on this ?):

$ grep kvm /lib/udev/rules.d/*udev*
/lib/udev/rules.d/70-udev-acl.rules:SUBSYSTEM=="misc", KERNEL=="kvm", TAG+="udev-acl"

did 18.04 drop that rule ? there also used to be a kvm group for systems that do not use acl:

$ ls -l /dev/kvm 
crw-rw----+ 1 root kvm 10, 232 Dez 10 17:32 /dev/kvm

you should always be able to add your user to that group as a fallback.

1 Like
$ grep kvm /lib/udev/rules.d/*udev*
#KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"
SUBSYSTEM=="ptp", ATTR{clock_name}=="KVM virtual PTP", SYMLINK += "ptp_kvm"
1 Like

Well, the comment in the first line of the output is your issue, i wonder why it is commented and why the udev-acl support for that device node was dropped (which would avoid the mode 666 evilness) … (again, probably a question jamie can answer)

1 Like

Confirmed exact same thing happens on my KDE Neon 18.04 system

$ qemu-virgil -enable-kvm -m 1024 -device virtio-vga,virgl=on -display sdl,gl=on -redir tcp:10022::22 ubuntu-core-16-amd64.img
qemu-system-x86_64: -redir tcp:10022::22: The -redir option is deprecated. Please use '-netdev user,hostfwd=...' instead.
Could not access KVM kernel module: Permission denied
qemu-system-x86_64: failed to initialize KVM: Permission denied

1 Like

just to make sure … and sinced i didnt ask yet, it runs with sudo, correct ?

Nope.

$ sudo qemu-virgil -enable-kvm -m 1024 -device virtio-vga,virgl=on -display sdl,gl=on -redir tcp:10022::22 ubuntu-core-16-amd64.img
[sudo] password for alan: 
qemu-system-x86_64: -redir tcp:10022::22: The -redir option is deprecated. Please use '-netdev user,hostfwd=...' instead.
qemu-system-x86_64: -redir tcp:10022::22: Could not open 'ubuntu-core-16-amd64.img': Permission denied

@popey, running as root seems to leave you with a plain ordinary home interface blocking of ~popey because you’re now root so $HOME is now ~root.

(~popey being e.g. /home/popey and ~root being /root)

1 Like

I’m currently using qemu-virgil from the stable channel. Everything works fine, but using the version in edge, I get an error on startup «audio: Could not init `pa’ audio driver» and there’s no sound although in the guest, everything looks like it’s working. In stable, this is not a problem.

I would like to give my VMs a nic that gets connected to a pre-existing bridge. I’m clueless how to do this. I’d be very happy if someone could help with this.