I have recently discovered that my laptop (LG Gram with i5-10210U) supports GPU virtualization.
This is a gamechanger as this allows to run pretty much any program that uses GPU with near native speed. And thus avoid pain of dual-booting.
Problem is that Intel GVT-g is kinda poorly documented. Well, at least I couldn’t find much information.
After following https://wiki.archlinux.org/title/Intel_GVT-g and https://blog.tmm.cx/2020/05/15/passing-an-intel-gpu-to-a-linux-kvm-virtual-machine/ I was able to boot Windows 10 with Intel GPU drivers via libvirt.
But I didn’t really like UI of virt-manager.
So I tried applying similar XML configs to Gnome boxes (after all, aren’t gnome boxes just front end for libvirt?)
But it refused to boot with “GVIR_DOMAIN_STATE_SHUTOFF” error.
Do Gnome-boxes support Intel GVT-g virtualization? If yes, how do I achieve this?
I will post logs a bit later, after I try again. Maybe I did something wrong.
Hi and welcome to the Forum
See https://www.spice-space.org/spice-user-manual.html and the Intel’s GVTg section, points to a blog about how to setup…
FWIW, I just used qemu direct to boot the vm’s.
FWIW, I just used qemu direct to boot the vm’s.
Thanks for advice, bare qemu actually works better than libvirt… But there is one catch…
I can’t make audio work (as I need to run this as root in order to get video working), and I really don’t want to change configs of PulseAudio…
How can I make qemu with gvt-g work under non-root user? Or what other audio options do I have?
This is my config
#!/bin/shenv INTEL_DEBUG norbc
exec qemu-system-x86_64 -enable-kvm \
-cpu host \
-smp 6,cores=3,threads=2,sockets=1 \
-drive file=iso.iso,media=cdrom \
-drive file=hdd.img \
-net nic,model=rtl8139 -net user,hostname=windowsvm \
-m 6G \
-vga none \
-display gtk,gl=on\
-monitor stdio \
-device vfio-pci,sysfsdev=/sys/bus/pci/devices/0000:00:02.0/cf46b956-0c8f-4cf2-ba50-3f4db4e765c4,display=on,x-igd-opregion=on,ramfb=on,driver=vfio-pci-nohotplug\
-name "Win10" \
-device ich9-intel-hda \
-device hda-micro,audiodev=hda\
-audiodev pa,id=hda,server=unix:/run/user/1000/pulse/native\
-usbdevice tablet
"$@"
Alex:
Thanks for advice, bare qemu actually works better than libvirt… But there is one catch…
I can’t make audio work (as I need to run this as root in order to get video working), and I really don’t want to change configs of PulseAudio…
How can I make qemu with gvt-g work under non-root user? Or what other audio options do I have?
This is my config
#!/bin/shenv INTEL_DEBUG norbc
exec qemu-system-x86_64 -enable-kvm \
-cpu host \
-smp 6,cores=3,threads=2,sockets=1 \
-drive file=iso.iso,media=cdrom \
-drive file=hdd.img \
-net nic,model=rtl8139 -net user,hostname=windowsvm \
-m 6G \
-vga none \
-display gtk,gl=on\
-monitor stdio \
-device vfio-pci,sysfsdev=/sys/bus/pci/devices/0000:00:02.0/cf46b956-0c8f-4cf2-ba50-3f4db4e765c4,display=on,x-igd-opregion=on,ramfb=on,driver=vfio-pci-nohotplug\
-name "Win10" \
-device ich9-intel-hda \
-device hda-micro,audiodev=hda\
-audiodev pa,id=hda,server=unix:/run/user/1000/pulse/native\
-usbdevice tablet
"$@"
Hi
You need to add the audio device, just like you did with 0000:00:02.0, I would guess it’s 0000:00:02.1 based on when I pass through a nvidia gpu and audio over hdmi.
You need to add the audio device, just like you did with 0000:00:02.0, I would guess it’s 0000:00:02.1 based on when I pass through a nvidia gpu and audio over hdmi.
I wanted to use qemu’s pulseaudio output. But I couldn’t run qemu as user for some reason.
But I think I fixed it. Finally.
Still not ideal (crackling and slight delay), but I don’t think I can do anything about it without using HDMI audio or USB sound card.
First, I changed /etc/security/limits.conf (added these two lines)
@kvm hard memlock 16777216
@kvm soft memlock 16777216
Then I added my user to kvm group, rebooted the system.
Then I changed permissions of /dev/vfio/
sudo chmod 777 -R /dev/vfio/
And launched qemu without root privileges without getting weird memory errors.
I still don’t understand why there is no easy one-click way to get gvt-g, especially given shear amount of laptop with Intel CPUs that support it…
And it is not like it is useless feature, as GPU even this weak is still way faster than anything qemu or virtualbox can emulate.
But I guess this is kinda becoming obsolete as Wine and Proton are getting better and better, but I still think virtualization/passthrough is better.
I think I finally reached my goal
<domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0" type="kvm">
<name>win10</name>
<uuid>dfc053b1-5edf-45a0-9c44-2a71ada635ec</uuid>
<title>hdd</title>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
<libosinfo:os id="http://microsoft.com/win/10"/>
</libosinfo:libosinfo>
<boxes:gnome-boxes xmlns:boxes="https://wiki.gnome.org/Apps/Boxes">
<os-state>installed</os-state>
<media>/run/media/eagle/0E004BC4004BB20F/win10vm1/hdd.img</media>
</boxes:gnome-boxes>
<edited:edited xmlns:edited="https://wiki.gnome.org/Apps/Boxes/edited">1629564174</edited:edited>
</metadata>
<memory unit="KiB">8392704</memory>
<currentMemory unit="KiB">8392468</currentMemory>
<vcpu placement="static">8</vcpu>
<os>
<type arch="x86_64" machine="pc-q35-6.0">hvm</type>
<boot dev="hd"/>
<bootmenu enable="no"/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode="host-passthrough" check="none" migratable="on">
<topology sockets="1" dies="1" cores="4" threads="2"/>
</cpu>
<clock offset="localtime">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2" cache="writeback"/>
<source file="/home/eagle/.local/share/gnome-boxes/images/win10"/>
<backingStore/>
<target dev="sda" bus="sata"/>
<address type="drive" controller="0" bus="0" target="0" unit="0"/>
</disk>
<disk type="file" device="cdrom">
<driver name="qemu" type="raw"/>
<target dev="hdc" bus="sata"/>
<readonly/>
<address type="drive" controller="0" bus="0" target="0" unit="2"/>
</disk>
<controller type="usb" index="0" model="qemu-xhci" ports="15">
<address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
</controller>
<controller type="sata" index="0">
<address type="pci" domain="0x0000" bus="0x00" slot="0x1f" function="0x2"/>
</controller>
<controller type="pci" index="0" model="pcie-root"/>
<controller type="pci" index="1" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="1" port="0x8"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0" multifunction="on"/>
</controller>
<controller type="pci" index="2" model="pcie-to-pci-bridge">
<model name="pcie-pci-bridge"/>
<address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
</controller>
<controller type="pci" index="3" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="3" port="0x9"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
</controller>
<controller type="pci" index="4" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="4" port="0xa"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x2"/>
</controller>
<controller type="pci" index="5" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="5" port="0xb"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x3"/>
</controller>
<controller type="pci" index="6" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="6" port="0xc"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x4"/>
</controller>
<controller type="virtio-serial" index="0">
<address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
</controller>
<controller type="ccid" index="0">
<address type="usb" bus="0" port="1"/>
</controller>
<interface type="user">
<mac address="52:54:00:42:21:7e"/>
<model type="rtl8139"/>
<address type="pci" domain="0x0000" bus="0x02" slot="0x01" function="0x0"/>
</interface>
<smartcard mode="passthrough" type="spicevmc">
<address type="ccid" controller="0" slot="0"/>
</smartcard>
<serial type="pty">
<target type="isa-serial" port="0">
<model name="isa-serial"/>
</target>
</serial>
<console type="pty">
<target type="serial" port="0"/>
</console>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
<address type="virtio-serial" controller="0" bus="0" port="1"/>
</channel>
<channel type="spiceport">
<source channel="org.spice-space.webdav.0"/>
<target type="virtio" name="org.spice-space.webdav.0"/>
<address type="virtio-serial" controller="0" bus="0" port="2"/>
</channel>
<input type="tablet" bus="usb">
<address type="usb" bus="0" port="2"/>
</input>
<input type="mouse" bus="ps2"/>
<input type="keyboard" bus="ps2"/>
<graphics type="spice">
<listen type="none"/>
<image compression="off"/>
<gl enable="yes"/>
</graphics>
<sound model="ich9">
<address type="pci" domain="0x0000" bus="0x00" slot="0x1b" function="0x0"/>
</sound>
<audio id="1" type="spice"/>
<video>
<model type="none"/>
</video>
<redirdev bus="usb" type="spicevmc">
<address type="usb" bus="0" port="3"/>
</redirdev>
<redirdev bus="usb" type="spicevmc">
<address type="usb" bus="0" port="4"/>
</redirdev>
<redirdev bus="usb" type="spicevmc">
<address type="usb" bus="0" port="5"/>
</redirdev>
<redirdev bus="usb" type="spicevmc">
<address type="usb" bus="0" port="6"/>
</redirdev>
<memballoon model="virtio">
<address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
</memballoon>
</devices>
<qemu:commandline>
<qemu:arg value="--device"/>
<qemu:arg value="vfio-pci,sysfsdev=/sys/bus/pci/devices/0000:00:02.0/cf46b956-0c8f-4cf2-ba50-3f4db4e765c4,display=on,x-igd-opregion=on,ramfb=on,driver=vfio-pci-nohotplug"/>
<qemu:env name="INTEL_DEBUG" value="norbc"/>
</qemu:commandline>
</domain>
This XML config seems to work with GNOME Boxes.
Trick is to add
<qemu:commandline>
<qemu:arg value="--device"/>
<qemu:arg value="vfio-pci,sysfsdev=/sys/bus/pci/devices/0000:00:02.0/cf46b956-0c8f-4cf2-ba50-3f4db4e765c4,display=on,x-igd-opregion=on,ramfb=on,driver=vfio-pci-nohotplug"/>
<qemu:env name="INTEL_DEBUG" value="norbc"/>
</qemu:commandline>
and set GL to enabled
And yes, all previous QEMU stuff also should be done (increase memory limit, kernel arguments, loat proper kernel modules etc.)
I should correct myself
@kvm hard memlock 16777216
@kvm soft memlock 16777216
In /etc/security/limits.conf in unstable VM that hangs the host.
Changing it to
@kvm soft memlock unlimited
@kvm hard memlock unlimited
Seems to help