Return to Level1Techs.com

[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">
  <name>Windoze_GVT</name>
  <uuid>3c5e73bd-fba0-4cf0-b024-a38814cc8d90</uuid>
  <title>Windoze GVT</title>
  <description>Windoze 10 With GVT-G</description>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://microsoft.com/win/10"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory unit="KiB">16777216</memory>
  <currentMemory unit="KiB">16777216</currentMemory>
  <vcpu placement="static">8</vcpu>
  <os>
    <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>
    <nvram>/var/lib/libvirt/qemu/nvram/Windoze_GVT_VARS.fd</nvram>
    <boot dev="hd"/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state="on"/>
      <vapic state="on"/>
      <spinlocks state="on" retries="8191"/>
    </hyperv>
    <vmport state="off"/>
  </features>
  <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"/>
  </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="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"/>
    </disk>
    <controller type="usb" index="0" model="qemu-xhci" ports="15">
      <address type="pci" domain="0x0000" bus="0x02" 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="0x10"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0" multifunction="on"/>
    </controller>
    <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>
    <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>
    <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>
    <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>
    <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>
    <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>
    <controller type="virtio-serial" index="0">
      <address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
    </controller>
    <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"/>
    </interface>
    <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>
    <input type="tablet" bus="usb">
      <address type="usb" bus="0" port="1"/>
    </input>
    <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"/>
    </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>
    <hostdev mode="subsystem" type="mdev" managed="no" model="vfio-pci" display="on">
      <source>
        <address uuid="71abd338-d32e-4a56-8f9a-5830d16a2828"/>
      </source>
      <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
    </hostdev>
    <redirdev bus="usb" type="spicevmc">
      <address type="usb" bus="0" port="2"/>
    </redirdev>
    <redirdev bus="usb" type="spicevmc">
      <address type="usb" bus="0" port="3"/>
    </redirdev>
    <memballoon model="virtio">
      <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
    </memballoon>
    <shmem name="looking-glass">
      <model type="ivshmem-plain"/>
      <size unit="M">32</size>
      <address type="pci" domain="0x0000" bus="0x07" slot="0x01" function="0x0"/>
    </shmem>
  </devices>
  <qemu:commandline>
    <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"/>
  </qemu:commandline>
</domain>

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

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

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

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
Extra

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)

https://forum.level1techs.com/t/looking-glass-host-not-finding-igpu/176519

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.

https://cdn.discordapp.com/attachments/677483619920510976/895452301110698085/unknown.png

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

Had to set

[os]
shmDevice=0

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?

<video>
  <model type="none"/>
</video>

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.

2 Likes

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!