[libvirt PATCH 6/9] 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>
---
 docs/schemas/domaincommon.rng                 |  8 +++++
 src/conf/domain_conf.c                        |  7 ++++
 src/conf/domain_conf.h                        |  1 +
 src/qemu/qemu_command.c                       | 12 +++++++
 .../graphics-dbus-clipboard.args              | 32 +++++++++++++++++
 .../graphics-dbus-clipboard.xml               | 36 +++++++++++++++++++
 tests/qemuxml2argvtest.c                      |  4 +++
 7 files changed, 100 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/graphics-dbus-clipboard.args
 create mode 100644 tests/qemuxml2argvdata/graphics-dbus-clipboard.xml

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index fcd14162bc9a..a8777acf9ea8 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4034,6 +4034,14 @@
                 </attribute>
               </element>
             </optional>
+            <optional>
+              <element name="clipboard">
+                <attribute name="copypaste">
+                  <ref name="virYesNo"/>
+                </attribute>
+                <empty/>
+              </element>
+            </optional>
           </interleave>
         </group>
         <group>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 82f5e44951d5..e249781ce027 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12940,6 +12940,13 @@ virDomainGraphicsDefParseXMLDBus(virDomainGraphicsDef *def,
             return -1;
     }
 
+    if ((cur = virXPathNode("./clipboard", ctxt))) {
+        if (virXMLPropTristateBool(cur, "copypaste",
+                                   VIR_XML_PROP_REQUIRED,
+                                   &def->data.dbus.copypaste) < 0)
+            return -1;
+    }
+
     return 0;
 }
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 6eec4230fab5..cc81dbd4a9db 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1924,6 +1924,7 @@ struct _virDomainGraphicsDef {
             char *rendernode;
             virTristateBool gl;
             unsigned int audioId;
+            virTristateBool copypaste;
         } dbus;
     } data;
     /* nListens, listens, and *port are only useful if type is vnc,
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 20cafa1abb0e..377e7e6f7623 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8614,6 +8614,7 @@ qemuBuildGraphicsDBusCommandLine(virQEMUDriver *driver,
                                  virCommand *cmd,
                                  virDomainGraphicsDef *graphics)
 {
+    g_autofree char *charAlias = NULL;
     g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
 
     if (!graphics->data.dbus.p2p && !graphics->data.dbus.address) {
@@ -8648,6 +8649,17 @@ qemuBuildGraphicsDBusCommandLine(virQEMUDriver *driver,
     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..a2de21f73130
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-dbus-clipboard.args
@@ -0,0 +1,32 @@
+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,accel=tcg,usb=off,dump-guest-core=off \
+-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 \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
+-display dbus,p2p=on \
+-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/qemuxml2argvdata/graphics-dbus-clipboard.xml b/tests/qemuxml2argvdata/graphics-dbus-clipboard.xml
new file mode 100644
index 000000000000..e6bf7c6b88a1
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-dbus-clipboard.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i386</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='dbus' p2p='yes'>
+      <clipboard copypaste='yes'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='16384' heads='1'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index e5454f03eccf..e1f032fe8a79 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1526,6 +1526,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.33.0.721.g106298f7f9




[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