Looking Glass

On this page 7

Looking Glass is an open-source application that copies the framebuffer of a virtual machine with a passed-through GPU into shared memory and displays it in a window on the Linux host with very low latency. In Linux virtualization, it solves a specific problem of VFIO GPU passthrough: the guest owns a physical graphics card whose output normally goes to a separate monitor, and Looking Glass makes that output visible on the host desktop without a second screen, a capture card or a video encoder.

The project is licensed under the GPLv2 and uses its own transport called KVMFR (KVM Frame Relay). It is aimed mainly at Windows guests used for games, creative software or engineering applications that need native GPU performance, while the user keeps working in the Linux host session.

How Looking Glass moves frames from guest to host

Looking Glass relies on a shared memory region between guest and host, exposed to the virtual machine as an IVSHMEM device (Inter-VM Shared Memory). Inside the guest, a capture program grabs each new frame from the GPU and writes it into that region; on the host, a client reads the same memory and draws the frame with OpenGL or EGL. No data passes through a network stack and no lossy compression is applied, so image quality equals the guest output.

The naming confuses many newcomers: the program that runs inside the Windows guest is called the host application, because it hosts the frames, while the program on the Linux machine is the client. Mouse and keyboard input travel back through a SPICE channel provided by QEMU, and the optional SPICE guest agent synchronizes the clipboard.

The table below summarizes the parts that must work together.

ComponentRuns whereRole
Host applicationWindows guestCaptures GPU frames and writes them to shared memory
ClientLinux hostReads frames and renders them in a window
IVSHMEM deviceQEMU virtual hardwareExposes the shared memory to the guest
kvmfr kernel moduleLinux host kernelOptional shared memory backend with DMA-BUF support
SPICE channelQEMUCarries keyboard, mouse and clipboard data
IVSHMEM driverWindows guestLets the host application access the shared memory
Components of a Looking Glass setup

Shared memory sizing and capture methods

The shared memory size must fit two full frames plus overhead. The documented rule is width times height times 4 bytes times 2, converted to mebibytes, plus about 10 MiB, rounded up to the next power of two. An undersized region causes the host application to fail or to fall back to lower resolutions.

Guest resolutionCalculated needConfigured size
1920 x 1080About 26 MiB32 MiB
2560 x 1440About 39 MiB64 MiB
3840 x 2160About 74 MiB128 MiB
Typical IVSHMEM sizes for SDR output

Higher bit depth or HDR output roughly doubles the memory per pixel, so those configurations need the next larger size. Capture itself uses either the DXGI Desktop Duplication API, which works with any Windows-compatible GPU, or NvFBC, an NVIDIA interface limited to certain professional cards. Direct3D 12 capture is available in recent releases and can lower overhead on modern drivers.

Looking Glass compared with other display paths

Looking Glass is one of several ways to see a passthrough VM’s output, and the right choice depends on whether the guest runs on the same machine as the viewer. Its advantage is local, uncompressed, low-latency viewing; its limitation is that it works only on the physical host.

MethodLatency and qualityMain constraint
Looking GlassVery low latency, losslessSame physical machine only
Second monitor or input switchNative, no added latencyExtra hardware and desk space
SPICE or VNC consoleHigh latency, emulated displayUnsuitable for GPU-accelerated work
Game streaming protocolsLow latency, lossy video encodingCompression artifacts and network dependence
Remote desktop protocolsVariable, optimized for office usePoor for full-screen 3D applications
Display options for a VM with a passed-through GPU

Looking Glass also differs from virtio-gpu and VirGL, which provide paravirtualized graphics without dedicating a physical card. Those approaches need no second GPU but offer far lower 3D performance and limited support for Windows guests.

Requirements and configuration in practice

A working setup starts with functional VFIO GPU passthrough under KVM and QEMU, typically managed through libvirt. The host needs IOMMU support enabled in firmware and kernel, and in most cases a second GPU or integrated graphics for the host desktop.

  1. Add an IVSHMEM device to the libvirt domain XML, or load the kvmfr module and point QEMU at its device file.
  2. Keep a SPICE display and input channel for keyboard, mouse and clipboard, while disabling the emulated video adapter where possible.
  3. Install the IVSHMEM driver and host application in the Windows guest and let it start as a service.
  4. Attach a display or an HDMI display emulator plug to the guest GPU, because many drivers render nothing without a detected monitor.
  5. Start the client on the Linux host with matching client and host application versions.

Version matching is strict: the client and the guest application must come from the same release, or the client refuses to connect. File permissions on the shared memory device and AppArmor or SELinux policies for QEMU are the other frequent causes of startup errors.

Limitations and common problems

Looking Glass narrows the gap to native output, but it does not remove every cost of a virtualized display.

SymptomLikely causeTypical fix
Black window or no framesGuest GPU has no detected displayConnect a monitor or display emulator plug
Client refuses to connectVersion mismatchInstall matching releases on both sides
Permission denied on shared memoryWrong owner or security policyAdjust device permissions and policy rules
Stutter at high refresh ratesMemory bandwidth or CPU pinning issuesPin vCPUs and use the kvmfr module
Capture fails on secure screensWindows protects login and UAC promptsUse the SPICE fallback for those screens
Frequent symptoms and their usual causes

Each frame is copied at least once, which consumes host memory bandwidth and CPU time, especially at 4K and high refresh rates. Anti-cheat software in some games blocks or detects virtual machines regardless of the display method, and Looking Glass cannot solve that.

Stripped to the essentials

Imagine a second computer hidden inside your main one, with its own powerful graphics card. Normally you would need a separate screen to see what it shows. Looking Glass acts like a window cut into the wall between the two computers. The picture from the hidden one appears in a normal window on your main desktop.

The picture travels through shared memory, not a cable or a network. It arrives almost instantly and without blurring. That is why people use it for games and graphics work.

Where it is applied

A 3D designer works on a Linux workstation with an integrated GPU for the desktop and a dedicated graphics card passed through to a Windows virtual machine. The Windows guest runs a CAD package and a rendering tool that have no Linux version. Instead of switching monitor inputs dozens of times a day, the designer configures a 64 MiB kvmfr shared memory region for a 2560 x 1440 guest display and attaches a small display emulator plug to the passed-through card.

The Looking Glass client runs in a resizable window next to Linux terminals and a browser. Viewport rotation in the CAD software feels as responsive as on bare metal, the clipboard works between both systems, and the second monitor previously reserved for the virtual machine is now used as extra workspace for the Linux desktop.