[Partially Solved] Can't figure out how to get looking glass to work with gvt-g

If I want to make spice display the GVT-G output, I have to tell it not to listen to any addresses/ports or I will get errors and the VM won’t run.

If I want to use Looking Glass, I need Spice to listen to localhost.

This is a working GVT-G config for my setup:

libvirt config
<domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0" type="kvm">
  <title>Windoze GVT</title>
  <description>Windoze 10 With GVT-G</description>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://microsoft.com/win/10"/>
  <memory unit="KiB">16777216</memory>
  <currentMemory unit="KiB">16777216</currentMemory>
  <vcpu placement="static">8</vcpu>
    <type arch="x86_64" machine="pc-q35-6.1">hvm</type>
    <loader readonly="yes" type="pflash">/usr/share/edk2-ovmf/x64/OVMF_CODE.fd</loader>
    <boot dev="hd"/>
      <relaxed state="on"/>
      <vapic state="on"/>
      <spinlocks state="on" retries="8191"/>
    <vmport state="off"/>
  <cpu mode="host-model" check="partial"/>
  <clock offset="localtime">
    <timer name="rtc" tickpolicy="catchup"/>
    <timer name="pit" tickpolicy="delay"/>
    <timer name="hpet" present="no"/>
    <timer name="hypervclock" present="yes"/>
    <suspend-to-mem enabled="no"/>
    <suspend-to-disk enabled="no"/>
    <disk type="file" device="disk">
      <driver name="qemu" type="raw"/>
      <source file="/home/rabcor/Windoze/vm-files/Windoze.img"/>
      <target dev="sda" bus="sata"/>
      <address type="drive" controller="0" bus="0" target="0" unit="0"/>
    <controller type="usb" index="0" model="qemu-xhci" ports="15">
      <address type="pci" domain="0x0000" bus="0x02" 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="0x10"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0" multifunction="on"/>
    <controller type="pci" index="2" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="2" port="0x11"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x1"/>
    <controller type="pci" index="3" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="3" port="0x12"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x2"/>
    <controller type="pci" index="4" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="4" port="0x13"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x3"/>
    <controller type="pci" index="5" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="5" port="0x14"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x4"/>
    <controller type="pci" index="6" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="6" port="0x15"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x5"/>
    <controller type="pci" index="7" model="pcie-to-pci-bridge">
      <model name="pcie-pci-bridge"/>
      <address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
    <controller type="virtio-serial" index="0">
      <address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
    <interface type="network">
      <mac address="52:54:00:cb:a9:1d"/>
      <source network="default"/>
      <model type="e1000e"/>
      <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
    <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"/>
    <input type="tablet" bus="usb">
      <address type="usb" bus="0" port="1"/>
    <input type="mouse" bus="ps2"/>
    <input type="keyboard" bus="ps2"/>
    <graphics type="spice">
      <listen type="none"/>
      <image compression="off"/>
      <gl enable="yes" rendernode="/dev/dri/by-path/pci-0000:00:02.0-render"/>
    <sound model="ich9">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1b" function="0x0"/>
    <audio id="1" type="spice"/>
      <model type="none"/>
    <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-pci" display="on">
        <address uuid="71abd338-d32e-4a56-8f9a-5830d16a2828"/>
      <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
    <redirdev bus="usb" type="spicevmc">
      <address type="usb" bus="0" port="2"/>
    <redirdev bus="usb" type="spicevmc">
      <address type="usb" bus="0" port="3"/>
    <memballoon model="virtio">
      <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
    <shmem name="looking-glass">
      <model type="ivshmem-plain"/>
      <size unit="M">32</size>
      <address type="pci" domain="0x0000" bus="0x07" slot="0x01" function="0x0"/>
    <qemu:arg value="-set"/>
    <qemu:arg value="device.hostdev0.romfile=/home/rabcor/Windoze/vm-files/vbios_gvt_uefi.rom"/>
    <qemu:arg value="-set"/>
    <qemu:arg value="device.hostdev0.x-igd-opregion=on"/>
    <qemu:arg value="-set"/>
    <qemu:arg value="device.hostdev0.ramfb=on"/>
    <qemu:arg value="-set"/>
    <qemu:arg value="device.hostdev0.driver=vfio-pci-nohotplug"/>

Result is as you can see here: https://cdn.discordapp.com/attachments/799390918205374485/894769144904429588/unknown.png

And perhaps unsurprisingly (given the spice configuration), looking glass client spits out:

$ looking-glass-client  
[I]  80329074488              main.c:1064 | main                           | Looking Glass (B4)
[I]  80329074505              main.c:1065 | main                           | Locking Method: Atomic
[I]  80329088632           ivshmem.c:127  | ivshmemOpenDev                 | KVMFR Device     : /dev/shm/looking-glass
[E]  80329088719              main.c:727  | lg_run                         | Failed to connect to spice server

The spice configuration is like this:

<graphics type="spice">
  <listen type="none"/>
  <image compression="off"/>
  <gl enable="yes" rendernode="/dev/dri/by-path/pci-0000:00:02.0-render"/>

As you can see the listen type is none, which would explain why the client has issues.

If I change it to this:

<graphics type="spice" autoport="yes">
  <listen type="address"/>
  <image compression="off"/>
  <gl enable="yes" rendernode="/dev/dri/by-path/pci-0000:00:02.0-render"/>

I get this error:

qemu-system-x86_64: SPICE GL support is local-only for now and incompatible with -spice port/tls-port

If I further change it to this:

<graphics type="spice" autoport="yes">
  <listen type="address"/>
  <image compression="off"/>

I get this error instead:

qemu-system-x86_64: ... vfio-display-dmabuf: opengl not available

Does anyone know how I should fix the config so that looking glass will work, without breaking the VM?

Partial Solution mentioned by Netboy3 below, is to run looking-glass-client -s, which provides a display output, but no direct HID & Clipboard support (because of no spice).

Solved Portion (host errors)

(Solution in one of my comments below)

However, the looking glass host fails to run:

Host Logs

Service Log

[2021-10-05 02:31:45] Startup
[2021-10-05 02:31:45] Host application exited with code 0x50
[2021-10-05 02:31:45] Host application failed to start with fatal error; will not restart
[2021-10-05 02:31:45] Finished

Looking Glass Host Log

[I]    217103125             delay.c:41   | delayInit                      | System timer resolution: 488200 ns
[W]    217104552          platform.c:495  | boostPriority                  | Failed to set realtime GPU priority.
[I]    217105543          platform.c:496  | boostPriority                  | This is not a failure, please do not report this as an issue.
[I]    217106745          platform.c:497  | boostPriority                  | To fix this, install and run the Looking Glass host as a service.
[I]    217108152          platform.c:498  | boostPriority                  | looking-glass-host.exe InstallService
[I]    217109113               app.c:514  | app_main                       | Looking Glass Host (B4)
   217117428 [E]            ivshmem.c:71   | ivshmemInit                    | Unable to enumerate the device, is it attached?: 0x00000103 (No more data is available.)
[E]    217118332               app.c:519  | app_main                       | Failed to find the IVSHMEM device
[I]     23332161             delay.c:41   | delayInit                      | System timer resolution: 488200 ns
[I]     23332730               app.c:514  | app_main                       | Looking Glass Host (B4)
    23337521 [E]            ivshmem.c:71   | ivshmemInit                    | Unable to enumerate the device, is it attached?: 0x00000103 (No more data is available.)
[E]     23337997               app.c:519  | app_main                       | Failed to find the IVSHMEM device
[I]     37451162             delay.c:41   | delayInit                      | System timer resolution: 488200 ns
[W]     37465824          platform.c:495  | boostPriority                  | Failed to set realtime GPU priority.
[I]     37480317          platform.c:496  | boostPriority                  | This is not a failure, please do not report this as an issue.
[I]     37497493          platform.c:497  | boostPriority                  | To fix this, install and run the Looking Glass host as a service.
[I]     37520981          platform.c:498  | boostPriority                  | looking-glass-host.exe InstallService
[I]     37535552               app.c:514  | app_main                       | Looking Glass Host (B4)
    37554417 [E]            ivshmem.c:71   | ivshmemInit                    | Unable to enumerate the device, is it attached?: 0x00000103 (No more data is available.)
[E]     37588184               app.c:519  | app_main                       | Failed to find the IVSHMEM device

I had another thread where I used a different libvirt config where the looking glass host failed, but for different reasons (it found the IVSHMEM Device, but was trying to use the QXL card instead of the iGPU)

Looking Glass Host not finding iGPU

Reason I’m not just continuing in that thread is because this has gone over to the territory of being an entirely different issue (now that there would be no GPU for looking glass to find except the iGPU, I imagine if the host wasn’t crashing for a different reason now).

Failed to find the IVSHMEM device

This is the problem, pretty clear. You have not added the ivshmem device to your VM, or you have not installed the drivers for it.

I can see you have it in your libvirt config, so the latter is the issue.

Also… why??
<size unit="M">512</size>

Are you planning on a 10k monitor or something?

I have the drivers installed and the ivshmem device was detected in my other config in the thread I linked to at the bottom, it was on the same vm, same image file, same host, different libvirt config but the ivshmem part is the same.

As for why 512mb I don’t really know what I’m doing, I assumed it should be set to whatever the max memory available to the igpu is.

Have you considered reading the documentation? Determining Memory

1 Like

Obviously, you don’t have the drivers installed or the device is not attached to the VM. We don’t log this message for any other reason.

Didn’t seem that important at the time, tweaking the memory was something I planned to do after getting it working at all in the first place, but thanks, 32 MB it is :slight_smile: .

@gnif I see you’re not convinced, and I completely understand why you wouldn’t be, so allow me to try to convince you.


Ah wait I managed to fix it, it was actually really simple.

Had to set


in C:\Program Files\Looking Glass (host)\looking-glass-host.ini

I set it to 1 a while back when I was trying to troubleshooting before, so this was my bad. :flushed:

Only problem now is the

Failed to connect to spice server

I’m editing the OP to reflect this (that includes the 32 bit memory setting).

1 Like

Don’t remove the virtual video device, leave it attached but change it’s type to none otherwise the spice server in qemu is disabled.

I’m afraid I might not be understanding you correctly, but do you mean this?

  <model type="none"/>

If so, that is already set in the config.

Correct. Note that if you have more than one VM your spice port may be different from the default, 5901 for example.

The problem isn’t the port, the problem, as described in the OP, is that I can only launch the VM with spice listen type set to none. meaning it’s not listening to any addresses which means it’s not listening to any ports either.

If I try to launch it with listen type set to address as we’d normally want, I just get errors.

The result is that I can view the VM display in virt-viewer, but not in looking glass.

This doesn’t seem to be an issue that is directly related to LG. You might get better advice as to how to deal with a misbehaving VM with a GVT-G passthrough in VFIO related discussion such as the VFIO Discord. LG requires spice for keyboard/mouse input. If all else fails, you can always run LG with the -s switch, thus disabling spice requirement, and using a different method for HID input such as EvDev or passing USB with those devices to the VM.


Oh my god, finally, it works! thank you.

Now I just gotta figure out the input.

Then again, now I wonder, since virt-viewer can connect to spice while spice is not listening to any addresses or ports, shouldn’t it be possible for looking glass to do this as well? If not currently then maybe in a future version?

Looking glass currently only supports spice network sockets. I’m not sure how virt viewer handles it when not using a network socket.

spice is a server<->client protocol by definition. you can’t run spice without a listener. when you set spice listen to “none” in libvirt, it either connects to an OpenGL render node (if you checkmark OpenGL) or falls back to local SDL. There are scenarios where LG needs to accept HID over the network (such as VM<->VM) so that type of local-only fallback is out of the question (I’m not sure if it’s even possible). SDL is also inferior to the current implementation of PureSPICE so there are no benefits there either. Without spice you will also loose clipboard functionality.

LG can also use a UNIX socket, not only network.

Oh, I looked very briefly in the help menu for that last night and couldn’t find it. Must have missed it!

I didn’t bother setting up a keyboard/mouse passthrough to get looking glass working with the -s switch.

But I wanted to chime in to say I did manage to make libvirt’s console display faster in such a way that it is now a perfectly good experience.

I just recompiled qemu with 60fps support according to this comment: Low framerate with dma-buf output · Issue #35 · intel/gvt-linux · GitHub

(that issue thread has been moved to here btw: GTK display refresh rate is throttled (#700) · Issues · QEMU / QEMU · GitLab )

And now it turns out I might actually not need looking glass in the first place :slight_smile: but to be fair, it still requires the mouse to use passthrough/usb-redirect (if i use the mouse normally (seamless mode?) it is still laggy in the libvirt console; if I use passthrough/redirect it’s smooth).

1 Like

Hey @rabcor, I’m intrigued.

Are you saying you got virgl working with a windows guest well enough that it gets acceptable gaming performance? This is only for OpenGL and not DirectX on windows, right?