From a5b55bd93106b8e678964f1dbf363dca3af76286 Mon Sep 17 00:00:00 2001 From: Jim Fehlig Date: Thu, 23 Apr 2015 17:00:26 -0600 Subject: [PATCH] xenconfig: fix spice mousemode and copypaste From xl.cfg950 man page: spiceagent_mouse=BOOLEAN Whether SPICE agent is used for client mouse mode. The default is true (1) (turn on) spicevdagent=BOOLEAN Enables spice vdagent. The Spice vdagent is an optional component for enhancing user experience and performing guest-oriented management tasks. Its features includes: client mouse mode (no need to grab mouse by client, no mouse lag), automatic adjustment of screen resolution, copy and paste (text and image) between client and domU. It also requires vdagent service installed on domU o.s. to work. The default is 0. spice_clipboard_sharing=BOOLEAN Enables Spice clipboard sharing (copy/paste). It requires spicevdagent enabled. The default is false (0). So if spiceagent_mouse is enabled (client mouse mode) or spice_clipboard_sharing is enabled, spicevdagent must be enabled. Along with this change, s/spicedvagent/spicevdagent, set spiceagent_mouse correctly, and add a test for these spice features. Signed-off-by: Jim Fehlig --- src/xenconfig/xen_xl.c | 56 ++++++++++++++++------ tests/xlconfigdata/test-spice-features.cfg | 32 +++++++++++++ tests/xlconfigdata/test-spice-features.xml | 48 +++++++++++++++++++ tests/xlconfigdata/test-spice.xml | 2 + tests/xlconfigtest.c | 1 + 5 files changed, 124 insertions(+), 15 deletions(-) create mode 100644 tests/xlconfigdata/test-spice-features.cfg create mode 100644 tests/xlconfigdata/test-spice-features.xml diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 92c12bf3d..0cb88cbcb 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -199,17 +199,23 @@ xenParseXLSpice(virConfPtr conf, virDomainDefPtr def) } if (xenConfigGetBool(conf, "spiceagent_mouse", - &graphics->data.spice.mousemode, 0) < 0) - goto cleanup; - if (xenConfigGetBool(conf, "spicedvagent", &val, 0) < 0) + &val, 0) < 0) goto cleanup; if (val) { - if (xenConfigGetBool(conf, "spice_clipboard_sharing", - &graphics->data.spice.copypaste, - 0) < 0) - goto cleanup; + graphics->data.spice.mousemode = + VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_CLIENT; + } else { + graphics->data.spice.mousemode = + VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_SERVER; } + if (xenConfigGetBool(conf, "spice_clipboard_sharing", &val, 0) < 0) + goto cleanup; + if (val) + graphics->data.spice.copypaste = VIR_TRISTATE_BOOL_YES; + else + graphics->data.spice.copypaste = VIR_TRISTATE_BOOL_NO; + if (VIR_ALLOC_N(def->graphics, 1) < 0) goto cleanup; def->graphics[0] = graphics; @@ -708,16 +714,36 @@ xenFormatXLSpice(virConfPtr conf, virDomainDefPtr def) return -1; } - if (xenConfigSetInt(conf, "spiceagent_mouse", - graphics->data.spice.mousemode) < 0) - return -1; + if (graphics->data.spice.mousemode) { + switch (graphics->data.spice.mousemode) { + case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_SERVER: + if (xenConfigSetInt(conf, "spiceagent_mouse", 0) < 0) + return -1; + break; + case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_CLIENT: + if (xenConfigSetInt(conf, "spiceagent_mouse", 1) < 0) + return -1; + /* + * spicevdagent must be enabled if using client + * mode mouse + */ + if (xenConfigSetInt(conf, "spicevdagent", 1) < 0) + return -1; + break; + default: + break; + } + } - if (graphics->data.spice.copypaste) { - if (xenConfigSetInt(conf, "spicedvagent", 1) < 0) + if (graphics->data.spice.copypaste == VIR_TRISTATE_BOOL_YES) { + if (xenConfigSetInt(conf, "spice_clipboard_sharing", 1) < 0) + return -1; + /* + * spicevdagent must be enabled if spice_clipboard_sharing + * is enabled + */ + if (xenConfigSetInt(conf, "spicevdagent", 1) < 0) return -1; - if (xenConfigSetInt(conf, "spice_clipboard_sharing", - graphics->data.spice.copypaste) < 0) - return -1; } } } diff --git a/tests/xlconfigdata/test-spice-features.cfg b/tests/xlconfigdata/test-spice-features.cfg new file mode 100644 index 000000000..c3e711186 --- /dev/null +++ b/tests/xlconfigdata/test-spice-features.cfg @@ -0,0 +1,32 @@ +name = "XenGuest2" +uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" +maxmem = 579 +memory = 394 +vcpus = 1 +pae = 1 +acpi = 1 +apic = 1 +hap = 0 +viridian = 0 +localtime = 0 +on_poweroff = "destroy" +on_reboot = "restart" +on_crash = "restart" +device_model = "/usr/lib/xen/bin/qemu-dm" +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] +parallel = "none" +serial = "none" +builder = "hvm" +boot = "d" +disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ] +sdl = 0 +vnc = 0 +spice = 1 +spicehost = "127.0.0.1" +spiceport = 590 +spicetls_port = 500 +spicedisable_ticketing = 0 +spicepasswd = "thebeast" +spiceagent_mouse = 1 +spicevdagent = 1 +spice_clipboard_sharing = 1 diff --git a/tests/xlconfigdata/test-spice-features.xml b/tests/xlconfigdata/test-spice-features.xml new file mode 100644 index 000000000..8f3fcf5b1 --- /dev/null +++ b/tests/xlconfigdata/test-spice-features.xml @@ -0,0 +1,48 @@ + + XenGuest2 + c7a5fdb2-cdaf-9455-926a-d65c16db1809 + 592896 + 403456 + 1 + + hvm + /usr/lib/xen/boot/hvmloader + + + + + + + + + destroy + restart + restart + + /usr/lib/xen/bin/qemu-dm + + + + + + + + + + + + + + +