I've been try to get QEMU/KVM working with accelerated 3D desktop for a while but I've always run into trouble. Now that most standard desktop Linux images use 3D graphics, and also browsers, it's a bit annoying if you want to test something out in a VM and it's really slow.
So when reading https://www.collabora.com/news-and-blog/blog/2018/02/12/virtualizing-gpu-access/ by Robert Foss I decided to give it another go. And this time it worked great!
Unfortunately the QEMU packages on Ubuntu are compiled with virglrenderer disabled. However it's quite easy to enable, so I thought I'd upload some packages to my PPA if anyone's interested:
That's all you need. And here's a (slightly modified) copy of Robert's instructions for using it:
wget http://releases.ubuntu.com/17.10/ubuntu-17.10.1-desktop-amd64.iso qemu-img create -f qcow2 ubuntu.qcow2 10G qemu-system-x86_64 \Share on Twitter Share on Facebook
-show-cursor \ -enable-kvm -M q35 -smp 2 -m 4G \ -drive file=ubuntu.qcow2,if=virtio \ -net nic,model=virtio \ -net user,hostfwd=tcp::2222-:22 \ -vga virtio \ -display sdl,gl=on \ -boot d -cdrom ubuntu-17.10.1-desktop-amd64.iso