Blame SOURCES/virt-manager-virt-install-add-support-for-qemu-vdagent-channel.patch

08b1ee
From 6ec78c1b8a935bd5fe0896dc323bfdf51cc67585 Mon Sep 17 00:00:00 2001
08b1ee
From: Jonathon Jongsma <jjongsma@redhat.com>
08b1ee
Date: Wed, 18 May 2022 17:03:29 -0500
08b1ee
Subject: [PATCH] virt-install: add support for qemu-vdagent channel
08b1ee
08b1ee
This allows support for host/guest clipboard sharing when using vnc
08b1ee
guests (and possibly other graphics types in the future). This channel
08b1ee
is similar to the spicevmc channel, but it contains a couple additional
08b1ee
options to enable/disable clipboard sharing and specify the mouse mode.
08b1ee
In the case of spice, these settings are specified on the 'graphics'
08b1ee
element, but for qemu-vdagent, they are specified on the channel. For
08b1ee
example:
08b1ee
08b1ee
   --channel=qemu-vdagent,source.clipboard.copypaste=on,source.mouse.mode=client
08b1ee
08b1ee
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
08b1ee
(cherry picked from commit 44355e5ed0d0791675e8113732dde37664d5aa91)
08b1ee
08b1ee
Resolves https://bugzilla.redhat.com/show_bug.cgi?id=2060724
08b1ee
08b1ee
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
08b1ee
---
08b1ee
 man/virt-install.rst                                 | 9 +++++++++
08b1ee
 tests/data/cli/compare/virt-install-many-devices.xml | 7 +++++++
08b1ee
 tests/test_cli.py                                    | 5 +++--
08b1ee
 virtinst/cli.py                                      | 2 ++
08b1ee
 virtinst/devices/char.py                             | 8 +++++++-
08b1ee
 5 files changed, 28 insertions(+), 3 deletions(-)
08b1ee
08b1ee
diff --git a/man/virt-install.rst b/man/virt-install.rst
08b1ee
index c1d1c1aa1..3a6e8dcd2 100644
08b1ee
--- a/man/virt-install.rst
08b1ee
+++ b/man/virt-install.rst
08b1ee
@@ -1761,6 +1761,15 @@ Some of the types of character device redirection are:
08b1ee
     and can be any string, such as the default com.redhat.spice.0 that
08b1ee
     specifies how the guest will see the channel.
08b1ee
 
08b1ee
+``--channel qemu-vdagent,target.type=virtio[,target.name=NAME]``
08b1ee
+    Communication channel for QEMU vd agent, using virtio serial (requires
08b1ee
+    2.6.34 or later host and guest). This allows copy/paste functionality with
08b1ee
+    VNC guests. Note that the guest clipboard integration is implemented via
08b1ee
+    spice-vdagent, which must be running even when the guest does not use spice
08b1ee
+    graphics. NAME is optional metadata that specifies how the guest will see
08b1ee
+    the channel, and should be left as the default com.redhat.spice.0 unless you
08b1ee
+    know what you are doing.
08b1ee
+
08b1ee
 
08b1ee
 Use --channel=? to see a list of all available sub options.
08b1ee
 Complete details at https://libvirt.org/formatdomain.html#elementsCharChannel
08b1ee
diff --git a/tests/data/cli/compare/virt-install-many-devices.xml b/tests/data/cli/compare/virt-install-many-devices.xml
08b1ee
index 4c0024225..be82032fe 100644
08b1ee
--- a/tests/data/cli/compare/virt-install-many-devices.xml
08b1ee
+++ b/tests/data/cli/compare/virt-install-many-devices.xml
08b1ee
@@ -647,6 +647,13 @@
08b1ee
     <channel type="spicevmc">
08b1ee
       <target type="virtio" name="com.redhat.spice.0"/>
08b1ee
     </channel>
08b1ee
+    <channel type="qemu-vdagent">
08b1ee
+      <source>
08b1ee
+        <clipboard copypaste="yes"/>
08b1ee
+        <mouse mode="client"/>
08b1ee
+      </source>
08b1ee
+      <target type="virtio" name="com.redhat.spice.0"/>
08b1ee
+    </channel>
08b1ee
     <input type="keyboard" bus="usb"/>
08b1ee
     <input type="tablet" bus="usb"/>
08b1ee
     <input type="mouse" bus="ps2"/>
08b1ee
diff --git a/tests/test_cli.py b/tests/test_cli.py
08b1ee
index 8b78a1a78..22749d43a 100644
08b1ee
--- a/tests/test_cli.py
08b1ee
+++ b/tests/test_cli.py
08b1ee
@@ -669,6 +669,7 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
08b1ee
 --channel pty,target_type=virtio,name=org.linux-kvm.port1
08b1ee
 --channel pty,target.type=virtio,target.name=org.linux-kvm.port2
08b1ee
 --channel spicevmc
08b1ee
+--channel qemu-vdagent,source.clipboard.copypaste=on,source.mouse.mode=client
08b1ee
 
08b1ee
 
08b1ee
 --console pty,target_type=virtio
08b1ee
@@ -734,7 +735,7 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
08b1ee
 
08b1ee
 
08b1ee
 --rng /dev/random
08b1ee
---rng device=/dev/urandom,backend.protocol.type=,backend.log.file=,backend.log.append=
08b1ee
+--rng device=/dev/urandom,backend.protocol.type=,backend.log.file=,backend.log.append=,backend.source.clipboard.copypaste=,backend.source.mouse.mode=
08b1ee
 --rng type=egd,backend.type=nmdm,backend.source.master=/dev/foo1,backend.source.slave=/dev/foo2
08b1ee
 --rng egd,backend_host=127.0.0.1,backend_service=8000,backend_type=udp,backend_mode=bind,backend_connect_host=foo,backend_connect_service=708,rate.bytes=1234,rate.period=1000,model=virtio
08b1ee
 
08b1ee
@@ -786,7 +787,7 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
08b1ee
 --xml xpath.delete=./deleteme/deleteme2
08b1ee
 
08b1ee
 
08b1ee
-""", "many-devices", predefine_check="7.4.0")
08b1ee
+""", "many-devices", predefine_check="8.4.0")
08b1ee
 
08b1ee
 
08b1ee
 # Specific XML test cases #1
08b1ee
diff --git a/virtinst/cli.py b/virtinst/cli.py
08b1ee
index 52be9f298..c869c323a 100644
08b1ee
--- a/virtinst/cli.py
08b1ee
+++ b/virtinst/cli.py
08b1ee
@@ -3396,6 +3396,8 @@ def _add_char_source_args(cls, prefix=""):
08b1ee
     _add_arg("protocol.type", "source.protocol")
08b1ee
     _add_arg("log.file", "source.log_file")
08b1ee
     _add_arg("log.append", "source.log_append", is_onoff=True)
08b1ee
+    _add_arg("source.clipboard.copypaste", "source.clipboard_copypaste", is_onoff=True)
08b1ee
+    _add_arg("source.mouse.mode", "source.mouse_mode")
08b1ee
 
08b1ee
 
08b1ee
 ##################
08b1ee
diff --git a/virtinst/devices/char.py b/virtinst/devices/char.py
08b1ee
index 9547c649e..01fc634b1 100644
08b1ee
--- a/virtinst/devices/char.py
08b1ee
+++ b/virtinst/devices/char.py
08b1ee
@@ -45,6 +45,10 @@ class CharSource(XMLBuilder):
08b1ee
     slave = XMLProperty("./@slave")
08b1ee
     mode = XMLProperty("./@mode")
08b1ee
 
08b1ee
+    # for qemu-vdagent channel
08b1ee
+    clipboard_copypaste = XMLProperty("./clipboard/@copypaste", is_yesno=True)
08b1ee
+    mouse_mode = XMLProperty("./mouse/@mode")
08b1ee
+
08b1ee
     # It's weird to track these properties here, since the XML is set on
08b1ee
     # the parent, but this is how libvirt does it internally, which means
08b1ee
     # everything that shares a charsource has these values too.
08b1ee
@@ -80,6 +84,7 @@ class _DeviceChar(Device):
08b1ee
     TYPE_SPICEVMC = "spicevmc"
08b1ee
     TYPE_SPICEPORT = "spiceport"
08b1ee
     TYPE_NMDM = "nmdm"
08b1ee
+    TYPE_QEMUVDAGENT = "qemu-vdagent"
08b1ee
 
08b1ee
     CHANNEL_NAME_SPICE = "com.redhat.spice.0"
08b1ee
     CHANNEL_NAME_QEMUGA = "org.qemu.guest_agent.0"
08b1ee
@@ -117,7 +122,8 @@ class _DeviceChar(Device):
08b1ee
             self.source.mode = "bind"
08b1ee
         if not self.target_type and self.DEVICE_TYPE == "channel":
08b1ee
             self.target_type = "virtio"
08b1ee
-        if not self.target_name and self.type == self.TYPE_SPICEVMC:
08b1ee
+        if not self.target_name and (self.type == self.TYPE_SPICEVMC or
08b1ee
+                self.type == self.TYPE_QEMUVDAGENT):
08b1ee
             self.target_name = self.CHANNEL_NAME_SPICE
08b1ee
 
08b1ee
 
08b1ee
-- 
08b1ee
2.35.3
08b1ee