7374756666

Improving spice performance over wan

When accessing a KVM virtual machine over WAN (the internet), I've noticed painfully slow performance.

It turns out that the default spice viewer when a machine is configured using virt-manager on Debian 11 doesn't have any compression settings enabled.

To fix it, run virsh edit MACHINENAME and find the <graphics> section and change it to this:

<graphics type='spice' port='-1' autoport='no' listen='0.0.0.0'>
  <listen type='address' address='0.0.0.0'/>
  <image compression='auto_glz'/>
  <jpeg compression='always'/>
  <zlib compression='always'/>
  <playback compression='on'/>
  <streaming mode='filter'/>
  <gl enable='no'/>
</graphics>

Note this enabled jpeg compression which does result in some lossy compression but I think it's worth it.

Also note this is an unencrypted connection without auth which in my case is fine since the connection is established over a VPN and everything is firewalled.

It took me forever to find the correct settings on the internet, hopefully this helps someone else

Note there are other values for which can be used:

<image compression="[auto_glz|auto_lz|quic|glz|lz|off]"/>
<jpeg compression="[auto|never|always]"/>
<zlib compression="[auto|never|always]"/>
<playback compression="[on|off]"/>
<streaming mode="[all|filter|off]"/>

I found that auto_glz is the best compression option.

Also make sure you use the QXL video driver not virtio.

You can also use the remote-viewer flags --spice-disable-effects=all --spice-disable-audio which disables audio and disables desktop effects.

I've tested this with Debian 11 guests and a quick test with a Windows 10 guest, it's a good idea to try different combinations and see what works best for you.

References: