[libvirt PATCH v3 12/16] qemu: add dbus clipboard sharing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

This feature requires to setup a "-chardev qemu-vdagent,clipboard=on".

"qemu-vdagent" is not a typical chardev that you can connect to another
end, so it doesn't map to a <serial> or <channel>. Set it up along with
"-display dbus" code instead.

Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
 src/qemu/qemu_command.c                       | 12 +++++++
 .../graphics-dbus-clipboard.args              | 31 +++++++++++++++++++
 tests/qemuxml2argvtest.c                      |  4 +++
 3 files changed, 47 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/graphics-dbus-clipboard.args

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8303a20bc8bd..bde3266f2148 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8590,6 +8590,7 @@ qemuBuildGraphicsDBusCommandLine(virDomainDef *def,
                                  virCommand *cmd,
                                  virDomainGraphicsDef *graphics)
 {
+    g_autofree char *charAlias = NULL;
     g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
 
     virBufferAddLit(&opt, "dbus");
@@ -8619,6 +8620,17 @@ qemuBuildGraphicsDBusCommandLine(virDomainDef *def,
     virCommandAddArg(cmd, "-display");
     virCommandAddArgBuffer(cmd, &opt);
 
+
+    if (graphics->data.dbus.copypaste == VIR_TRISTATE_BOOL_YES) {
+        if (!(charAlias = qemuAliasChardevFromDevAlias("qemu-vdagent")))
+            return -1;
+
+        virBufferAsprintf(&opt, "qemu-vdagent,id=%s", charAlias);
+        virBufferAddLit(&opt, ",clipboard=on");
+        virCommandAddArg(cmd, "-chardev");
+        virCommandAddArgBuffer(cmd, &opt);
+    }
+
     return 0;
 }
 
diff --git a/tests/qemuxml2argvdata/graphics-dbus-clipboard.args b/tests/qemuxml2argvdata/graphics-dbus-clipboard.args
new file mode 100644
index 000000000000..fd0c3e7a253e
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-dbus-clipboard.args
@@ -0,0 +1,31 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-i386 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
+-machine pc,usb=off,dump-guest-core=off \
+-accel tcg \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-usb \
+-display dbus,addr=unix:path=/bad-test-used-env-xdg-runtime-dir/libvirt/qemu/run/dbus/-1-QEMUGuest1-dbus.sock \
+-chardev qemu-vdagent,id=charqemu-vdagent,clipboard=on \
+-device cirrus-vga,id=video0,bus=pci.0,addr=0x2 \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 37fc7120b6ed..3510bcce6cff 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1610,6 +1610,10 @@ mymain(void)
             QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DISPLAY_DBUS);
     DO_TEST("graphics-dbus-audio",
             QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DISPLAY_DBUS, QEMU_CAPS_AUDIODEV);
+    DO_TEST("graphics-dbus-clipboard",
+            QEMU_CAPS_DEVICE_CIRRUS_VGA,
+            QEMU_CAPS_DISPLAY_DBUS,
+            QEMU_CAPS_CHARDEV_VDAGENT);
 
     DO_TEST_NOCAPS("input-usbmouse");
     DO_TEST_NOCAPS("input-usbtablet");
-- 
2.34.1.8.g35151cf07204




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux