OPINIONATED OMARCHY
TROUBLESHOOTING CORPUS
790
RECORDS
790
AUDITED
0
UNCHECKED
2388
SOURCES
LIVE
apps-services low very-common DISPUTE

Get clipboard sharing and window auto-resize working in a Linux VM guest

omarchyarchendeavouroscachyosmanjarohyprlandwaylandkvmlibvirtdesktoplaptop
CORRECTED An auditor found the fix wrong or incomplete and rewrote it.
AUDIT NOTE

Two hard errors. (1) The Lua is invalid: hl.monitor takes a single table with the output as a key. The 0.55 wiki's own examples are hl.monitor({ output = "", mode = "preferred", position = "auto", scale = 2 }) and hl.monitor({ output = "Unknown-1", disabled = true }). hl.monitor("", { ... }) passes a string where the table is expected and will throw a Hyprland type error, so the reader's monitor config silently does not apply. (2) The clipboard cause is wrong: spice-vdagent has no Wayland support. Upstream's README describes it as 'a per X-session process' whose features are X-session clipboard/selection and Xrandr resolution adjustment. Installing wl-clipboard does not bridge it to a Wayland compositor's clipboard, so a Hyprland guest will still have no host/guest copy-paste after following this record. That is exactly the symptom the reader arrived with ('installing spice-vdagent in the guest did not help'). The host-side XML (spice graphics, virtio video, spicevmc channel with com.redhat.spice.0), the /dev/virtio-ports check, and the 'use virt-viewer not VNC' guidance are all correct and worth keeping.

The cause above was not rewritten and may still contain the error described. The fix below is the corrected version.

Symptom

Copy/paste between host and a QEMU/KVM guest does nothing in either direction, and resizing the virt-manager/virt-viewer window leaves the guest stuck at 1024x768 with black bars instead of following the window. Installing spice-vdagent in the guest did not help.

Cause

Clipboard and resize are two different mechanisms with different requirements. Both need the VM to have a SPICE display plus the com.redhat.spice.0 virtio-serial channel. Resize then works in a Wayland guest through the virtio-gpu display-info/EDID update: the host sends the new size, the guest's virtio-gpu DRM driver exposes a new preferred mode, and the compositor follows it, provided the video model is virtio and the guest's monitor config does not pin a mode. Clipboard, however, is done by spice-vdagent, which is X11-only by design (upstream describes it as a per-X-session process using X selections and Xrandr). In a bare Wayland guest such as Hyprland there is no X session for it to attach to, so host/guest copy-paste does not work no matter what is installed. wl-clipboard is a local CLI tool and is unrelated to the SPICE agent.

Fix

Host side is unchanged: SPICE display, virtio video model, and the spicevmc channel targeting com.redhat.spice.0 (virt-manager: Display Spice + Add Hardware > Channel > Spice agent), and connect with virt-viewer/remote-viewer rather than a VNC client.

**Resize (works on Wayland guests).** Install the agent and daemon in the guest for the mouse/resize plumbing:


sudo pacman -S --needed spice-vdagent
sudo systemctl enable --now spice-vdagentd.service
ls -l /dev/virtio-ports/          # expect com.redhat.spice.0

Then leave the guest output free to change mode. Note the correct Lua call shape, a single table with output as a key:


-- ~/.config/hypr/hyprland.lua
hl.monitor({ output = "", mode = "preferred", position = "auto", scale = 1 })

A hard-coded mode = "1920x1080@60" pins the guest and defeats auto-resize. Check with hyprctl monitors. If the mode never changes, confirm the guest is on virtio-gpu (lsmod | grep virtio_gpu) rather than QXL. QXL resize depends on the X11 agent.

**Clipboard.** spice-vdagent cannot do this in a Wayland session. Do not expect wl-clipboard to help. Pick one:

  • run the guest desktop as an X11 session (or a guest DE whose XWayland setup spice-vdagent can attach to) if SPICE clipboard is the requirement
  • or use a protocol with native Wayland clipboard support instead of SPICE for that guest, e.g. RDP into the guest (gnome-remote-desktop / a wlroots-compatible RDP or VNC server with clipboard support)
  • or move data over a virtiofs share or ssh rather than the clipboard.

SPICE's own note still applies: QEMU's GTK display has no supported clipboard path in Arch's qemu-ui-gtk build.

Verify

In the guest, systemctl --user status spice-vdagent.service is active and /dev/virtio-ports/com.redhat.spice.0 exists. Copying text in the host pastes in the guest, and dragging the viewer window changes the resolution reported by hyprctl monitors.

Sources

vm-guest-no-clipboard-or-auto-resize