Forcing initial Frame Transmission for dmabuf encoding on SPICE display channel connection

Michael Scherle michael.scherle at rz.uni-freiburg.de
Thu Apr 10 14:04:35 UTC 2025


Hello,

I’ve encountered an issue with the new DMA-BUF -> video encoding feature 
in SPICE. When connecting, the first frame is only sent once the GPU 
renders a new frame. However, this can take quite some time if the VM is 
idle (e.g., sitting on the desktop), since the GPU only renders a new 
frame when something on the screen changes. To address this, I wanted to 
force a frame to be sent when the display channel is connected.

My initial, naive attempt was to grab the latest DMA-BUF on the display 
channel's connection in the SPICE server, encode it, and send it. 
However, this led to race conditions and crashes—particularly when QEMU 
happened to perform a scanout at the same time, closing the DMA-BUF in 
the process.

As a second approach, I modified the QXLInterface to pass the display 
channel on_connect event back to QEMU. I couldn’t find any existing 
mechanism in QEMU to detect the connection of a display channel. Within 
QEMU, I then used qemu_spice_gl_monitor_config, and spice_gl_refresh to 
trigger a spice_gl_draw. This solution works, but the downside is that 
it requires changes to SPICE, QEMU, and especially the 
QXLInterface—which is obviously not ideal.

So now I’m wondering: does anyone have a better idea for how to tackle 
this problem?

Best regards,
Michael


More information about the Spice-devel mailing list