Intel GVT-g and Gnome Boxes

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 and 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 :slight_smile:
See 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

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="" type="kvm"> 
    <libosinfo:libosinfo xmlns:libosinfo=""> 
      <libosinfo:os id=""/> 
    <boxes:gnome-boxes xmlns:boxes=""> 
    <edited:edited xmlns:edited="">1629564174</edited:edited> 
  <memory unit="KiB">8392704</memory> 
  <currentMemory unit="KiB">8392468</currentMemory> 
  <vcpu placement="static">8</vcpu> 
    <type arch="x86_64" machine="pc-q35-6.0">hvm</type> 
    <boot dev="hd"/> 
    <bootmenu enable="no"/> 
  <cpu mode="host-passthrough" check="none" migratable="on"> 
    <topology sockets="1" dies="1" cores="4" threads="2"/> 
  <clock offset="localtime"> 
    <timer name="rtc" tickpolicy="catchup"/> 
    <timer name="pit" tickpolicy="delay"/> 
    <timer name="hpet" present="no"/> 
    <suspend-to-mem enabled="no"/> 
    <suspend-to-disk enabled="no"/> 
    <disk type="file" device="disk"> 
      <driver name="qemu" type="qcow2" cache="writeback"/> 
      <source file="/home/eagle/.local/share/gnome-boxes/images/win10"/> 
      <target dev="sda" bus="sata"/> 
      <address type="drive" controller="0" bus="0" target="0" unit="0"/> 
    <disk type="file" device="cdrom"> 
      <driver name="qemu" type="raw"/> 
      <target dev="hdc" bus="sata"/> 
      <address type="drive" controller="0" bus="0" target="0" unit="2"/> 
    <controller type="usb" index="0" model="qemu-xhci" ports="15"> 
      <address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/> 
    <controller type="sata" index="0"> 
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1f" function="0x2"/> 
    <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 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 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 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 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 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 type="virtio-serial" index="0"> 
      <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/> 
    <controller type="ccid" index="0"> 
      <address type="usb" bus="0" port="1"/> 
    <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"/> 
    <smartcard mode="passthrough" type="spicevmc"> 
      <address type="ccid" controller="0" slot="0"/> 
    <serial type="pty"> 
      <target type="isa-serial" port="0"> 
        <model name="isa-serial"/> 
    <console type="pty"> 
      <target type="serial" port="0"/> 
    <channel type="spicevmc"> 
      <target type="virtio" name="com.redhat.spice.0"/> 
      <address type="virtio-serial" controller="0" bus="0" port="1"/> 
    <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"/> 
    <input type="tablet" bus="usb"> 
      <address type="usb" bus="0" port="2"/> 
    <input type="mouse" bus="ps2"/> 
    <input type="keyboard" bus="ps2"/> 
    <graphics type="spice"> 
      <listen type="none"/> 
      <image compression="off"/> 
      <gl enable="yes"/> 
    <sound model="ich9"> 
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1b" function="0x0"/> 
    <audio id="1" type="spice"/> 
      <model type="none"/> 
    <redirdev bus="usb" type="spicevmc"> 
      <address type="usb" bus="0" port="3"/> 
    <redirdev bus="usb" type="spicevmc"> 
      <address type="usb" bus="0" port="4"/> 
    <redirdev bus="usb" type="spicevmc"> 
      <address type="usb" bus="0" port="5"/> 
    <redirdev bus="usb" type="spicevmc"> 
      <address type="usb" bus="0" port="6"/> 
    <memballoon model="virtio"> 
      <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/> 
    <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"/> 

This XML config seems to work with GNOME Boxes.
Trick is to add

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

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