From 896e6ac4f8f61318b9633fe6233b42f8eb88bde4 Mon Sep 17 00:00:00 2001 From: Peng Zhou Date: Fri, 9 Mar 2012 15:26:24 +0800 Subject: [PATCH] qemu: spice agent-mouse support spice agent-mouse support Usage: Signed-off-by: Osier Yang --- AUTHORS | 1 + docs/formatdomain.html.in | 8 +++++ docs/schemas/domaincommon.rng | 11 ++++++ src/conf/domain_conf.c | 32 ++++++++++++++++- src/conf/domain_conf.h | 10 ++++++ src/libvirt_private.syms | 2 ++ src/qemu/qemu_command.c | 14 ++++++++ ...emuxml2argv-graphics-spice-agentmouse.args | 8 +++++ ...qemuxml2argv-graphics-spice-agentmouse.xml | 36 +++++++++++++++++++ tests/qemuxml2argvtest.c | 3 ++ 10 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agentmouse.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agentmouse.xml diff --git a/AUTHORS b/AUTHORS index 954fd1a68e..e4bd51df12 100644 --- a/AUTHORS +++ b/AUTHORS @@ -224,6 +224,7 @@ Patches have also been contributed by: Peter Robinson Benjamin Cama Duncan Rance + Peng Zhou [....send patches to get your name here....] diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 7710c5bb4d..bf0675e65f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2851,6 +2851,7 @@ qemu-kvm -net nic,model=? /dev/null <image compression='auto_glz'/> <streaming mode='filter'/> <clipboard copypaste='no'/> + <mouse mode='client'/> </graphics>

Spice supports variable compression settings for audio, @@ -2883,6 +2884,13 @@ qemu-kvm -net nic,model=? /dev/null to no, since 0.9.3.

+

+ Mouse mode is set by the mouse element, + setting it's mode attribute to one of + server or client , + since 0.9.11. If no mode is + specified, the qemu default will be used (client mode). +

"rdp"
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 073ad37d66..646a51b748 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1826,6 +1826,17 @@ + + + + + server + client + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 333b10eab3..b185fe79af 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -465,6 +465,12 @@ VIR_ENUM_IMPL(virDomainGraphicsSpicePlaybackCompression, "on", "off"); +VIR_ENUM_IMPL(virDomainGraphicsSpiceMouseMode, + VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_LAST, + "default", + "server", + "client"); + VIR_ENUM_IMPL(virDomainGraphicsSpiceStreamingMode, VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_LAST, "default", @@ -6180,6 +6186,26 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, VIR_FREE(copypaste); def->data.spice.copypaste = copypasteVal; + } else if (xmlStrEqual(cur->name, BAD_CAST "mouse")) { + const char *mode = virXMLPropString(cur, "mode"); + int modeVal; + + if (!mode) { + virDomainReportError(VIR_ERR_XML_ERROR, "%s", + _("spice mouse missing mode")); + goto error; + } + + if ((modeVal = virDomainGraphicsSpiceMouseModeTypeFromString(mode)) <= 0) { + virDomainReportError(VIR_ERR_XML_ERROR, + _("unknown mouse mode value '%s'"), + mode); + VIR_FREE(mode); + goto error; + } + VIR_FREE(mode); + + def->data.spice.mousemode = modeVal; } } cur = cur->next; @@ -11896,7 +11922,8 @@ virDomainGraphicsDefFormat(virBufferPtr buf, } if (!children && (def->data.spice.image || def->data.spice.jpeg || def->data.spice.zlib || def->data.spice.playback || - def->data.spice.streaming || def->data.spice.copypaste)) { + def->data.spice.streaming || def->data.spice.copypaste || + def->data.spice.mousemode)) { virBufferAddLit(buf, ">\n"); children = 1; } @@ -11915,6 +11942,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf, if (def->data.spice.streaming) virBufferAsprintf(buf, " \n", virDomainGraphicsSpiceStreamingModeTypeToString(def->data.spice.streaming)); + if (def->data.spice.mousemode) + virBufferAsprintf(buf, " \n", + virDomainGraphicsSpiceMouseModeTypeToString(def->data.spice.mousemode)); if (def->data.spice.copypaste) virBufferAsprintf(buf, " \n", virDomainGraphicsSpiceClipboardCopypasteTypeToString(def->data.spice.copypaste)); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 0f40f1d721..6fc307e3c1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1135,6 +1135,14 @@ enum virDomainGraphicsSpicePlaybackCompression { VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_LAST }; +enum virDomainGraphicsSpiceMouseMode { + VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_DEFAULT = 0, + VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_SERVER, + VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_CLIENT, + + VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_LAST +}; + enum virDomainGraphicsSpiceStreamingMode { VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_DEFAULT = 0, VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_FILTER, @@ -1202,6 +1210,7 @@ struct _virDomainGraphicsDef { struct { int port; int tlsPort; + int mousemode; char *keymap; virDomainGraphicsAuthDef auth; unsigned int autoport :1; @@ -2124,6 +2133,7 @@ VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression) VIR_ENUM_DECL(virDomainGraphicsSpicePlaybackCompression) VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode) VIR_ENUM_DECL(virDomainGraphicsSpiceClipboardCopypaste) +VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode) VIR_ENUM_DECL(virDomainNumatuneMemMode) VIR_ENUM_DECL(virDomainSnapshotState) /* from libvirt.h */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2a0b4d5b16..d7ec221b63 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -345,6 +345,8 @@ virDomainGraphicsSpiceImageCompressionTypeFromString; virDomainGraphicsSpiceImageCompressionTypeToString; virDomainGraphicsSpiceJpegCompressionTypeFromString; virDomainGraphicsSpiceJpegCompressionTypeToString; +virDomainGraphicsSpiceMouseModeTypeFromString; +virDomainGraphicsSpiceMouseModeTypeToString; virDomainGraphicsSpicePlaybackCompressionTypeFromString; virDomainGraphicsSpicePlaybackCompressionTypeToString; virDomainGraphicsSpiceStreamingModeTypeFromString; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d95064f85a..0ef3e30855 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5424,6 +5424,20 @@ qemuBuildCommandLine(virConnectPtr conn, VIR_FREE(netAddr); + int mm = def->graphics[0]->data.spice.mousemode; + if (mm) { + switch (mm) { + case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_SERVER: + virBufferAsprintf(&opt, ",agent-mouse=off"); + break; + case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_CLIENT: + virBufferAsprintf(&opt, ",agent-mouse=on"); + break; + default: + break; + } + } + /* In the password case we set it via monitor command, to avoid * making it visible on CLI, so there's no use of password=XXX * in this bit of the code */ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agentmouse.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agentmouse.args new file mode 100644 index 0000000000..2c3ef06128 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agentmouse.args @@ -0,0 +1,8 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \ +/usr/bin/qemu -S -M pc -m 214 -smp 1 -nodefconfig -nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \ +-hda /dev/HostVG/QEMUGuest1 -chardev spicevmc,id=charchannel0,name=vdagent \ +-device virtserialport,bus=virtio-serial1.0,nr=3,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 \ +-usb -spice port=5903,tls-port=5904,addr=127.0.0.1,agent-mouse=off,x509-dir=/etc/pki/libvirt-spice,tls-channel=main \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agentmouse.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agentmouse.xml new file mode 100644 index 0000000000..facc7acf04 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agentmouse.xml @@ -0,0 +1,36 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + + + +
+ + + + + + + +
+ + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 0abc9cf0db..3cfd69c2c1 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -511,6 +511,9 @@ mymain(void) DO_TEST("graphics-spice", false, QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE); + DO_TEST("graphics-spice-agentmouse", false, + QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL, + QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE); DO_TEST("graphics-spice-compression", false, QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE); -- GitLab