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

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