Allow compression when unix socket is used and the client requests it implicitly (spice over network through ssh)
Hello team,
Requirement: access console of virtual machines over unix socket through ssh tunnel and avail the WAN compression algos that exist already and is available if you access the spice server over network, ie port 5900 directly.
The issue:
1.) Configure a windows 10 KVM guest with the following display settings in libvirt:
<graphics type='spice'>
<listen type='socket' socket='/var/lib/libvirt/qemu/domain-15-VM1/spice.sock'/>
<image compression='lz'/>
<jpeg compression='always'/>
<zlib compression='always'/>
<playback compression='off'/>
<streaming mode='filter'/>
<gl enable='no'/>
</graphics>
QEMU representation: -spice unix,addr=/var/lib/libvirt/qemu/domain-15-VM1/spice.sock,disable-ticketing,image-compression=lz,jpeg-wan-compression=always,zlib-glz-wan-compression=always,playback-compression=off,streaming-video=filter,seamless-migration=on
2.) virt-viewer -c "qemu+ssh://REMOTEHOST/system" --spice-disable-effects=all and connect to VM1
3.) Drag any window (ie: Windows explorer) on a 1Gbps LAN connection and observe the network utilization spike up to as high as 950Mbps at times filling the link.
Expected result:
Apply the compression on the unix socket connection if this was implicitly requested with the above QEMU parameters and behave as if accessing the spice server on TCP port directly. This will lower the bandwidth and make the VM console responsive when accessed over unix socket through SSH.
What has been attempted, which does not provide satisfactory results:
1.) Enable compression on the SSH connection, this lowers bandwidth but the user experience is still impacted and not acceptable
Additional thoughts and discussions(as per #virt channel):
Perhaps to do with:
https://gitlab.freedesktop.org/spice/spice/blob/master/server/dcc-send.c#L440
if (red_stream_get_family(red_channel_client_get_stream(rcc)) == AF_UNIX ||
!dcc_compress_image(dcc, &image, &simage->u.bitmap,
drawable, can_lossy, &comp_send_data)) {
System information:
Kernel: 5.1.3-gentoo
Related package versions:
app-emulation/qemu-4.0.0-r3:0, app-emulation/spice-0.14.0-r2:0, app-emulation/spice-protocol-0.12.14:0, net-misc/spice-gtk-0.35:0, app-emulation/libvirt-5.2.0-r2:0
Thank you, -Nik