PDA

View Full Version : How to test 3D acceleration in virt-manager.



dd_wizard
3rd July 2016, 05:19 AM
Make sure you have audit >= 2.6.2-1, see Bug 1351995 (https://bugzilla.redhat.com/show_bug.cgi?id=1351995). It's in updates-testing at the moment. Install virt-viewer, it works much better than the virt-manager built-in viewer. Download the F24 Cinnamon spin live DVD. In virt-manager, open File > Add Connection... select "QEMU/KVM user session" for the Hypervisor. Back in the virt-manager GUI. right click on "QEMU/KVM user session" and create a new VM. Initially, create a diskless VM by connecting the CDROM device to the F24 Cinnamon iso. Boot into the live image and power it down. Follow the instructions here (http://blog.wikichoon.com/2016/05/spice-openglvirgl-acceleration-on.html), shown below for my VM.


$ virt-xml --connect qemu:///session fedora-live --confirm --edit --video clearxml=yes,model=virtio,accel3d=yes

$ virt-xml --connect qemu:///session fedora-live --confirm --edit --graphics clearxml=yes,type=spice,gl=on,listen=none

Right-click your VM and run it. In a terminal, type "virt-viewer -a fedora-live" or whatever you named your VM. You should not get the software rendering warning when the VM reboots. Also, all the host selinux errors I got earlier are fixed. You know 3D accelleration is working if you see:


$ glxinfo | grep renderer
GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer,
GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer,
Extended renderer info (GLX_MESA_query_renderer):
OpenGL renderer string: Gallium 0.4 on virgl

dd_wizard
4th July 2016, 10:12 PM
Here's an update. If you run "ip link", you should see that virt-manager has set up virbr0 for you. When you create the VM, change from user space networking to virbr0. It's much faster. Also, the 3.6 kernels do not work in the VM, so don't try to boot them. Also, selinux must be set to permissive or disabled. Using enforcing won't let the VM start.

dd_wizard

Dutchy
4th July 2016, 10:22 PM
This is great. I surely will try it out!
What OpenGL level is exposed (I guess some Mesa maximum like 4.0-4.3-ish) and what is the performance like (comparable to the host)?
I hope it will be much more stable and functional than the VirtualBox solution (it crashes nouveau and is unusable for even light gaming).

dd_wizard
5th July 2016, 07:13 PM
I see around 50 FpS on extreme tux racer with Intel HD4000 graphics. The most useful improvement is Cinnamon desktop itself, it's much smoother. As I said in my second post, there are still some selinux issues, even though I don't see any AVC denial messages.

dd_wizard

kajinofe
7th July 2016, 01:10 AM
Thanks for the tips!

nonamedotc
7th July 2016, 03:00 AM
Stuck the thread

Thanks dd_wizard for the nice guide.

bedtime
16th July 2017, 08:28 PM
I hope I am not intruding, but I would like to share my virgl script as well as an alternative, if that's okay; it took me so long to finally figure out how to get qemu running nicely that I thought I'd share it and save people the hassel (and potential hairloss).

This script is for running qemu itself, without virt-manager, as some people with older machines prefer to do, and it's the same result; glxinfo spat out the same stuff. The performance is simply awesome. Youtube uses at least about half the CPU power on both host and vm, it shaved about 1/3 off my bootup time.

myfedorascript:

/usr/bin/qemu-system-x86_64 \
-cpu host \
-smp 1,sockets=1,cores=1,threads=1 \
-soundhw hda \
-device AC97 \
-machine accel=kvm,usb=off,vmport=off \
-m 1024M \
-vga virtio \
-display gtk,gl=on \
-drive file=/vm/fedora.img,format=raw,if=virtio,aio=threads,cache= writeback \
-device virtio-serial \
-netdev user,id=vmnic,hostname=localhost \
-device virtio-net,netdev=vmnic \
-show-cursor \
-usbdevice tablet \
-nodefconfig \
-nodefaults \
$1 \

To run, change 'fedora.img' to whatever file you intend to run. Adjust '1024M' to whatever memory you would like to use. You may add additional parameters to the script as I did with '-snapshot,' which, in this case, doesn't not change the raw image but creates a new temporary image and then deletes it upon shutdown. Great for messing around and trying new things. I haven't been able to use -snapshot in virt-manager; it seems that they haven't added it in yet:


./myfedorascript '-snapshot'

Enjoy! :)