guest: Disable spice image compression for local VMs

The image compression setting has a noticably detrimental effect on
spice graphics quality. It's meant to be used for spice VDI but the
vast majority of people don't use spice in a way that makes bandwidth
usage matter.

Boxes has already done this for a while as well:

https://mail.gnome.org/archives/commits-list/2013-March/msg14904.html

Turn it off by default if creating the VM on a local connection.
This commit is contained in:
Cole Robinson 2015-04-11 17:35:40 -04:00
parent e9495110ca
commit a2c7d62ec4
27 changed files with 186 additions and 38 deletions

View File

@ -53,7 +53,9 @@
<model type="e1000"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -50,7 +50,9 @@
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -0,0 +1,66 @@
<domain type="kvm">
<name>foobar</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<memory>65536</memory>
<currentMemory>65536</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="x86_64">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<cpu mode="custom" match="exact">
<model>core2duo</model>
</cpu>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2"/>
<source file="/dev/default-pool/testvol1.img"/>
<target dev="vda" bus="virtio"/>
</disk>
<controller type="usb" index="0" model="ich9-ehci1"/>
<controller type="usb" index="0" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="bridge">
<source bridge="eth0"/>
<mac address="00:11:22:33:44:55"/>
<model type="virtio"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>
<target type="virtio" name="org.qemu.guest_agent.0"/>
</channel>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<sound model="ich6"/>
<video>
<model type="qxl"/>
</video>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
</devices>
</domain>

View File

@ -48,7 +48,9 @@
<model type="virtio"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>
@ -114,7 +116,9 @@
<model type="virtio"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>

View File

@ -47,7 +47,9 @@
<model type="virtio"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<video>
<model type="qxl"/>
</video>
@ -100,7 +102,9 @@
<model type="virtio"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<video>
<model type="qxl"/>
</video>

View File

@ -48,7 +48,9 @@
<model type="virtio"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>
@ -114,7 +116,9 @@
<model type="virtio"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>

View File

@ -48,7 +48,9 @@
<model type="virtio"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>
@ -114,7 +116,9 @@
<model type="virtio"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>

View File

@ -50,7 +50,9 @@
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
@ -114,7 +116,9 @@
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
@ -178,7 +182,9 @@
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -44,7 +44,9 @@
<master startport="4"/>
</controller>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
@ -100,7 +102,9 @@
<master startport="4"/>
</controller>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -177,9 +177,13 @@
<input type="keyboard" bus="usb"/>
<input type="tablet" bus="xen"/>
<graphics type="sdl" display=":3.4" xauth="/tmp/.Xauthority"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<graphics type="vnc" port="5950" keymap="ja" listen="1.2.3.4" passwd="foo"/>
<graphics type="spice" port="5950" tlsPort="5950" keymap="ja" listen="1.2.3.4"/>
<graphics type="spice" port="5950" tlsPort="5950" keymap="ja" listen="1.2.3.4">
<image compression="off"/>
</graphics>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="foo"/>
<streaming mode="bar"/>

View File

@ -24,7 +24,9 @@
<source file="/dev/default-pool/testvol1.img"/>
<target dev="sda" bus="scsi"/>
</disk>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>

View File

@ -24,7 +24,9 @@
<source file="/dev/default-pool/testvol1.img"/>
<target dev="sda" bus="scsi"/>
</disk>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>

View File

@ -53,7 +53,9 @@
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
@ -118,7 +120,9 @@
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -42,7 +42,9 @@
<model type="virtio"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -45,7 +45,9 @@
<master startport="4"/>
</controller>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<video>
<model type="vga"/>
</video>

View File

@ -55,7 +55,9 @@
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
@ -124,7 +126,9 @@
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
@ -193,7 +197,9 @@
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -78,6 +78,7 @@ test_files = {
'DEFAULTURI' : utils.defaulturi,
'REMOTEURI' : utils.uriremote,
'KVMURI' : utils.urikvm,
'REMOTEKVMURI' : utils.urikvm + ",remote",
'KVMURI_NODOMCAPS' : utils.urikvm_nodomcaps,
'XENURI' : utils.urixencaps,
'XENIA64URI' : utils.urixenia64,
@ -779,6 +780,7 @@ c.add_invalid("--nodisks --boot network --arch mips --virt-type kvm") # Invalid
c.add_invalid("--nodisks --boot network --paravirt --arch mips") # Invalid arch/virt combo
c.add_compare("--os-variant win7 --cdrom %(EXISTIMG2)s --boot loader_type=pflash,loader=CODE.fd,nvram_template=VARS.fd --disk %(EXISTIMG1)s", "win7-uefi") # no HYPER-V
c.add_compare("--machine q35 --cdrom %(EXISTIMG2)s --disk %(EXISTIMG1)s", "q35-defaults") # proper q35 disk defaults
c.add_compare("--connect %(REMOTEKVMURI)s --import --disk %(EXISTIMG1)s --os-variant fedora21", "f21-kvm-remote")
######################

View File

@ -47,7 +47,9 @@
<model type="e1000"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -53,7 +53,9 @@
<model type="e1000"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -53,7 +53,9 @@
<model type="e1000"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -48,7 +48,9 @@
<model type="e1000"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -45,7 +45,9 @@
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -50,7 +50,9 @@
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -50,7 +50,9 @@
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -51,7 +51,9 @@
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>

View File

@ -1022,10 +1022,7 @@ class Guest(XMLBuilder):
sound.model = default
def _set_graphics_defaults(self):
for gfx in self.get_devices("graphics"):
if gfx.type != "default":
continue
def _set_type(gfx):
gtype = self.default_graphics_type
logging.debug("Using default_graphics=%s", gtype)
if (gtype == "spice" and not
@ -1034,8 +1031,22 @@ class Guest(XMLBuilder):
logging.debug("spice requested but HV doesn't support it. "
"Using vnc.")
gtype = "vnc"
gfx.type = gtype
for dev in self.get_devices("graphics"):
if dev.type == "default":
_set_type(dev)
if (dev.type == "spice" and
not self.conn.is_remote() and
self.conn.check_support(
self.conn.SUPPORT_CONN_SPICE_COMPRESSION)):
logging.debug("Local connection, disabling spice image "
"compression.")
if dev.image_compression is None:
dev.image_compression = "off"
def _add_spice_channels(self):
if self.skip_default_channel:
return

View File

@ -304,6 +304,7 @@ SUPPORT_CONN_DOMAIN_CAPABILITIES = _make(
run_args=(None, None, None, None))
SUPPORT_CONN_VIDEO_NEW_RAM_OUTPUT = _make(version="1.2.11")
SUPPORT_CONN_DOMAIN_RESET = _make(version="0.9.7", hv_version={"qemu": 0})
SUPPORT_CONN_SPICE_COMPRESSION = _make(version="0.9.1")
# Domain checks