SPICE vdagent version mismatch causes resolution change issues
I'm having the same problem and found some additional information that may be useful for debugging.
Guest OS has spice-vdagent & spice-vdagentd running, but when resizing the UTM window the spice-vdagentd log shows the following:
● spice-vdagentd.service - Agent daemon for Spice guests
Loaded: loaded (/usr/lib/systemd/system/spice-vdagentd.service; indirect; vendor preset: disabled)
Active: active (running) since Sun 2022-05-29 13:30:57 CEST; 3s ago
TriggeredBy: ● spice-vdagentd.socket
Process: 868 ExecStart=/usr/bin/spice-vdagentd $SPICE_VDAGENTD_EXTRA_ARGS (code=exited, status=0/SUCCESS)
Main PID: 869 (spice-vdagentd)
Tasks: 2 (limit: 11808)
Memory: 1.1M
CPU: 9ms
CGroup: /system.slice/spice-vdagentd.service
└─869 /usr/bin/spice-vdagentd
May 29 13:30:57 derp systemd[1]: Starting Agent daemon for Spice guests...
May 29 13:30:57 derp systemd[1]: Started Agent daemon for Spice guests.
May 29 13:30:57 derp spice-vdagentd[869]: opening vdagent virtio channel
May 29 13:30:57 derp spice-vdagentd[869]: Set max clipboard: 104857600
May 29 13:30:57 derp spice-vdagentd[869]: invalid message size for VDAgentMonitorsConfig
May 29 13:30:57 derp spice-vdagentd[869]: Set max clipboard: 104857600
May 29 13:30:57 derp spice-vdagentd[869]: invalid message size for VDAgentMonitorsConfig
I quickly checked the spice-vdagentd source code, and this message is logged in spice-vdagentd.c on line 212 when the service receives a monitor configuration message with an unexpected message body size:
static void do_client_monitors(VirtioPort *vport, int port_nr,
VDAgentMessage *message_header, VDAgentMonitorsConfig *new_monitors)
{
VDAgentReply reply;
uint32_t size;
/* Store monitor config to send to agents when they connect */
size = sizeof(VDAgentMonitorsConfig) +
new_monitors->num_of_monitors * sizeof(VDAgentMonConfig);
if (message_header->size != size) {
syslog(LOG_ERR, "invalid message size for VDAgentMonitorsConfig");
return;
}
It seems as if the side that sends the monitor config message (UTM/QEMU) and the side that receives it (the spice-vdagentd inside the VM) are using a different protocol, possibly some mismatch in the SPICE version used to build UTM and the one in the VM? The spice-vdagent in Arch is version 0.22.1 released three months ago.
I did try to find some clues in the UTM source code but it seems this code that sends this message is somewhere in a QEMU or SPICE dependency, and building all that myself seems complicated.
UTM Version 3.2.4 (58) Host OS: macOS Monterey 12.4 Guest OS: Arch Linux aarch64 with i3 desktop environment Apple MacBook 14" M1 Pro
Originally posted by @w0utert in https://github.com/utmapp/UTM/issues/4064#issuecomment-1140419702
That's interesting, thanks. Can you downgrade spice-vdagent and see if that makes a difference? We're using an older version of spice on the host side and I wonder if anything changed in how that structure is sized.
I see this in my own logs every time I resize, and also just before the graphics stop working.
@osy What version of spice are you using on the host side in UTM ?
https://github.com/utmapp/UTM/blob/main/patches/sources#L36
I'm also seeing this issue on GNU Guix when attempting to use something like:
qemu-system-x86_64 [...] -m 5g -display spice-app -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x6 -chardev spicevmc,name=vdagent,id=vdagent -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,name=com.redhat.spice.0
QEMU is built using [email protected], which uses [email protected] and [email protected].
virt-viewer uses [email protected]
[email protected] uses [email protected]
All these are the latest releases, so I'd expect they'd be compatible.
I am running NixOS 24.11 and installed the guest tools that way, but I am encountering the same issue.
Apr 29 19:06:12 jamzig-vm spice-vdagentd[870]: invalid message size for VDAgentMonitorsConfig
I am running NixOS 24.11 and installed the guest tools that way, but I am encountering the same issue.
Apr 29 19:06:12 jamzig-vm spice-vdagentd[870]: invalid message size for VDAgentMonitorsConfig
I experienced a similar issue in NixOS from UTM on macOS:
- Display resizing on gnome desktop wasn't working
- I saw the error
spice-vdagentd[686]: invalid message size for VDAgentMonitorsConfigin the logs viajournalctl -xfeu spice-vdagentd.service
What didn't work:
- commands I found in other issues using the
xrandrcommand - using the nixpkgs unstable version of
spice-vdagent
What worked:
- Changed UTM emulated display card to
virtio-ramfb-gl (GPU Supported)
Using the nixpkgs-unstable version of spice-vdagent didn't matter. I reverted to (stable) version 0.22.1.
I still see the error invalid message size for VDAgentMonitorsConfig in the logs but resizing works now.
Turns out this is a bug in spice-vdagent: https://gitlab.freedesktop.org/spice/linux/vd_agent/-/commit/3660acfcbaaca9c66dca5ef09205bd7c1d70b98c
I will patch out this in our SPICE client code because we don't use this feature anyways.
FYI with this issue fixed, you will still see No QXL devices found, not generating xorg.conf since QXL is not supported on QEMU ARM64. This one, unfortunately, cannot be fixed client side because it depends on the vdagent code supporting resize on other kinds of video adapters.
Note that if you use virtio-gpu (not running in ramfb mode), the resize is not handled by SPICE but by QEMU virtio code. But your guest OS has to support that in its virtio-gpu driver.
Applying the above patch (3660acfcbaaca9c66dca5ef09205bd7c1d70b98c) to spice-vdagent seems to have gotten rid of the error messages, thank you! If I make sure to use -device qxl-vga with QEMU, the resolution appears to change correctly when using the qemu system arguments: -m 5g -display spice-app -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x6 -chardev spicevmc,name=vdagent,id=vdagent -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,name=com.redhat.spice.0 -device qxl-vga
I did see the following warnings:
(remote-viewer:32219): Gtk-WARNING **: 07:56:27.575: VirtViewerDisplaySpice 0x557f2dd47100 reported min size 200 and natural size 32 in get_preferred_height(); natural size must be >= min size
(remote-viewer:32219): Gtk-WARNING **: 07:56:27.575: VirtViewerDisplaySpice 0x557f2dd47100 reported min size 320 and natural size 32 in get_preferred_width(); natural size must be >= min size
(remote-viewer:32219): Gdk-WARNING **: 07:57:45.884: ../gtk+-3.24.43/gdk/wayland/gdkcursor-wayland.c:513 cursor image size (89x89) not an integermultiple of scale (2)
Anyway, thanks for pointing to the fix for the earlier problem!
On NixOS/Wayland/Sway, I got it to autodetect resolution on boot by using nixpkgs-unstable spice-vdagent (0.23.0) since stable only has 0.22.x.
virtio-ramfb-gl (GPU Supported)doesn't seem to work for me- I use
virtio-gpu-gl-pci(GPU Supported)
It can't change resolution on window change, but it's slightly more convenient that I don't have to hardcode the resolution.
Not much of a contribution, but I found this through google trying to solve this issue and that's all I got.