Resizing the window of a KVM/QEMU virtual machine changes the virtual display mode, but at least under Xfce the X desktop does not follow: the guest keeps the old resolution, with black borders or a scrollable viewport around it.
Fix: react to the DRM mode change in the guest. Create ~/.local/bin/vmx.sh
#!/bin/sh
udevadm monitor --udev --subsystem-match=drm | while read -r _; do
xrandr --output Virtual-1 --auto
done
Make it executable and add it to the session autostart (Xfce: Settings -> Session and Startup -> Application Autostart). From then on every resize of the VM window on the host is picked up and the desktop resizes with it.
Notes:
- The output name has to match the virtual display of the guest. Check with xrandr; Virtual-1 is what the QXL / virtio-gpu driver typically reports, but it can also be Virtual1 or XWAYLAND0.
- udevadm monitor –udev waits for processed events, so xrandr runs after the kernel already knows the new mode. The read -r _ only consumes one line per event; its content does not matter.
- –auto picks the preferred mode, which is exactly the one the host just set.
- Only needed for X11 sessions. Wayland compositors handle the virtio-gpu mode change themselves.
Comment: why Xfce needs this and GNOME does not
The host does send the new size. With auto-resize enabled in the viewer, the SPICE client sends a monitors_config message, spice-vdagentd receives it over the virtio-serial channel and forwards it to the session agent. The agent demonstrably acts on it: it rebuilds its uinput tablet device for the new geometry. It just never applies the resolution.
The reason is that spice-vdagent 0.23 does not configure the display itself on X11. It delegates to GNOME’s mutter over D-Bus, calling GetCurrentState on org.gnome.Mutter.DisplayConfig to read the current layout before applying the new one. Under Xfce no process owns that bus name, the call fails with “without an owner”, and the new size is discarded. Nothing is reported to the user; the only related log line is an unrelated fallback about mapping outputs to display ids, which makes the failure look harmless.
Nothing else in the stack steps in, and that part is by design. In X11 an output’s mode list is a catalogue of what is possible, and “preferred” is advice from the hardware rather than an instruction; actually switching requires a client to issue RandR requests. The X server deliberately holds no policy, because resizing the logical screen affects every other output, window position and panel. Xfce’s xfsettingsd does listen for RandR events, but its rules are keyed on monitors being connected or disconnected and on matching EDIDs against saved profiles. An already-connected output that changes its preferred mode matches none of them, because physical hardware cannot produce that event. Virtual displays invented a new category and the desktop’s rulebook has no entry for it.
Verified on one and the same guest configuration: GNOME resizes out of the box on both Wayland and Xorg, Xfce on X11 does not. The X11 stack is identical in both cases, only the presence of mutter differs. KDE Plasma is untested: on Wayland, KWin is the display server and handles the mode change itself, so it should be unaffected; on X11 it depends on whether kscreen acts on a preferred-mode change of a connected output.
On X11 this dependency is unnecessary. RandR has been the universal, desktop-agnostic display-configuration API for twenty years, and the few lines of shell above do the job for any desktop. Routing the apply path through a GNOME-only service, with no fallback and nothing reported to the user, turns a solved problem into a per-desktop lottery. On Wayland there is no universal API and a compositor-specific backend is justified; on X11 it is a choice, and it is the wrong one.
Symptom to confirm the diagnosis: after a resize, xrandr shows the new size as the preferred mode, marked with a plus, while the current mode is still the old size. The kernel already holds the right answer, because QEMU creates a custom mode matching the window, the DRM driver marks it preferred and fires a uevent on the drm subsystem. The script above simply adopts it with –auto.