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

846839
From e4e7210b3bd669bfeb8015f66163e7e49d710d1d Mon Sep 17 00:00:00 2001
846839
From: Jonathon Jongsma <jjongsma@redhat.com>
846839
Date: Wed, 18 May 2022 17:03:30 -0500
846839
Subject: [PATCH] virt-manager: add support for qemu-vdagent channel
846839
846839
 This provides the UI support for the qemu-vdagent channel which allows
846839
 clipboard sharing with VNC graphics (see previous commit for more
846839
 information).
846839
846839
 The channel name in the device list was changed slightly in order to
846839
 avoid confusion. Due to the fact that both the spice-vdagent and the
846839
 qemu-vdagent specify the same virtio name (com.redhat.spice.0), both of
846839
 these channels were showing up in the device list as "Channel spice",
846839
 which is a bit confusing.
846839
846839
 In order to disambiguate these, channels now show up in the device list
846839
 as "Channel {type} ({name})" instead of "Channel {name}". So for
846839
 example, a qemu-vdagent channel would show up as:
846839
    Channel Qemu vdagent (spice)
846839
Whereas a spice-vdagent channel would show up as:
846839
    Channel Spice agent (spice)
846839
846839
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
846839
(cherry picked from commit caa99a6001be0c86a1dd0eb5fc0ce142ab929a31)
846839
846839
Resolves https://bugzilla.redhat.com/show_bug.cgi?id=2060724
846839
846839
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
846839
---
846839
 ui/addhardware.ui              | 28 +++++++++++++++++++++++++++-
846839
 ui/details.ui                  | 27 ++++++++++++++++++++++++++-
846839
 virtManager/addhardware.py     | 10 +++++++++-
846839
 virtManager/details/details.py |  7 +++++--
846839
 4 files changed, 67 insertions(+), 5 deletions(-)
846839
846839
diff --git a/ui/addhardware.ui b/ui/addhardware.ui
846839
index fa88127b8..f212481a3 100644
846839
--- a/ui/addhardware.ui
846839
+++ b/ui/addhardware.ui
846839
@@ -725,7 +725,7 @@
846839
                               </packing>
846839
                             </child>
846839
                             <child>
846839
-                              
846839
+                              
846839
                               <object class="GtkGrid" id="char-table">
846839
                                 <property name="visible">True</property>
846839
                                 <property name="can-focus">False</property>
846839
@@ -901,6 +901,32 @@
846839
                                     <property name="top-attach">2</property>
846839
                                   </packing>
846839
                                 </child>
846839
+                                <child>
846839
+                                  <object class="GtkLabel" id="char-vdagent-clipboard-label">
846839
+                                    <property name="visible">True</property>
846839
+                                    <property name="can-focus">False</property>
846839
+                                    <property name="label" translatable="yes">_Share Clipboard:</property>
846839
+                                    <property name="use-underline">True</property>
846839
+                                    <property name="mnemonic-widget">char-vdagent-clipboard</property>
846839
+                                  </object>
846839
+                                  <packing>
846839
+                                    <property name="left-attach">0</property>
846839
+                                    <property name="top-attach">6</property>
846839
+                                  </packing>
846839
+                                </child>
846839
+                                <child>
846839
+                                  <object class="GtkCheckButton" id="char-vdagent-clipboard">
846839
+                                    <property name="visible">True</property>
846839
+                                    <property name="can-focus">True</property>
846839
+                                    <property name="receives-default">False</property>
846839
+                                    <property name="halign">start</property>
846839
+                                    <property name="draw-indicator">True</property>
846839
+                                  </object>
846839
+                                  <packing>
846839
+                                    <property name="left-attach">1</property>
846839
+                                    <property name="top-attach">6</property>
846839
+                                  </packing>
846839
+                                </child>
846839
                                 <child internal-child="accessible">
846839
                                   <object class="AtkObject" id="char-table-atkobject">
846839
                                     <property name="AtkObject::accessible-name">char-tab</property>
846839
diff --git a/ui/details.ui b/ui/details.ui
846839
index 10b308242..264f7cdd4 100644
846839
--- a/ui/details.ui
846839
+++ b/ui/details.ui
846839
@@ -3506,7 +3506,7 @@
846839
                             <property name="margin-start">12</property>
846839
                             <property name="margin-top">3</property>
846839
                             <child>
846839
-                              
846839
+                              
846839
                               <object class="GtkGrid" id="table37">
846839
                                 <property name="visible">True</property>
846839
                                 <property name="can-focus">False</property>
846839
@@ -3601,6 +3601,19 @@
846839
                                     <property name="top-attach">6</property>
846839
                                   </packing>
846839
                                 </child>
846839
+                                <child>
846839
+                                  <object class="GtkLabel" id="char-clipboard-sharing">
846839
+                                    <property name="visible">True</property>
846839
+                                    <property name="can-focus">False</property>
846839
+                                    <property name="halign">start</property>
846839
+                                    <property name="label" translatable="yes">label507</property>
846839
+                                    <property name="selectable">True</property>
846839
+                                  </object>
846839
+                                  <packing>
846839
+                                    <property name="left-attach">1</property>
846839
+                                    <property name="top-attach">7</property>
846839
+                                  </packing>
846839
+                                </child>
846839
                                 <child>
846839
                                   <object class="GtkLabel" id="char-source-host">
846839
                                     <property name="visible">True</property>
846839
@@ -3673,6 +3686,18 @@
846839
                                     <property name="top-attach">6</property>
846839
                                   </packing>
846839
                                 </child>
846839
+                                <child>
846839
+                                  <object class="GtkLabel" id="char-clipboard-sharing-label">
846839
+                                    <property name="visible">True</property>
846839
+                                    <property name="can-focus">False</property>
846839
+                                    <property name="halign">end</property>
846839
+                                    <property name="label" translatable="yes">Clipboard:</property>
846839
+                                  </object>
846839
+                                  <packing>
846839
+                                    <property name="left-attach">0</property>
846839
+                                    <property name="top-attach">7</property>
846839
+                                  </packing>
846839
+                                </child>
846839
                                 <child>
846839
                                   <object class="GtkLabel" id="char-source-path-label">
846839
                                     <property name="visible">True</property>
846839
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
846839
index 8c7fa0c72..0a8e33d30 100644
846839
--- a/virtManager/addhardware.py
846839
+++ b/virtManager/addhardware.py
846839
@@ -308,6 +308,7 @@ class vmmAddHardware(vmmGObjectUI):
846839
         self.widget("char-path").set_text("")
846839
         self.widget("char-channel").set_text("")
846839
         self.widget("char-auto-socket").set_active(True)
846839
+        self.widget("char-vdagent-clipboard").set_active(True)
846839
 
846839
 
846839
         # RNG params
846839
@@ -399,7 +400,8 @@ class vmmAddHardware(vmmGObjectUI):
846839
                DeviceSerial.TYPE_UNIX]
846839
         if char_class.XML_NAME == "channel":
846839
             ret = [DeviceSerial.TYPE_SPICEVMC,
846839
-                   DeviceSerial.TYPE_SPICEPORT] + ret
846839
+                   DeviceSerial.TYPE_SPICEPORT,
846839
+                   DeviceSerial.TYPE_QEMUVDAGENT] + ret
846839
         return ret
846839
 
846839
     @staticmethod
846839
@@ -425,6 +427,7 @@ class vmmAddHardware(vmmGObjectUI):
846839
             DeviceSerial.TYPE_UNIX: _("UNIX socket"),
846839
             DeviceSerial.TYPE_SPICEVMC: _("Spice agent"),
846839
             DeviceSerial.TYPE_SPICEPORT: _("Spice port"),
846839
+            DeviceSerial.TYPE_QEMUVDAGENT: _("QEMU vdagent"),
846839
         }
846839
         return labels.get(val, val)
846839
 
846839
@@ -1114,11 +1117,14 @@ class vmmAddHardware(vmmGObjectUI):
846839
         supports_path = [dev.TYPE_FILE, dev.TYPE_UNIX,
846839
                          dev.TYPE_DEV, dev.TYPE_PIPE]
846839
         supports_channel = [dev.TYPE_SPICEPORT]
846839
+        supports_clipboard = [dev.TYPE_QEMUVDAGENT]
846839
 
846839
         uiutil.set_grid_row_visible(self.widget("char-path-label"),
846839
                 devtype in supports_path)
846839
         uiutil.set_grid_row_visible(self.widget("char-channel-label"),
846839
                 devtype in supports_channel)
846839
+        uiutil.set_grid_row_visible(self.widget("char-vdagent-clipboard-label"),
846839
+                devtype in supports_clipboard)
846839
 
846839
         uiutil.set_grid_row_visible(
846839
             self.widget("char-target-name-label"), ischan)
846839
@@ -1472,6 +1478,7 @@ class vmmAddHardware(vmmGObjectUI):
846839
         source_channel = self.widget("char-channel").get_text()
846839
         target_name = self.widget("char-target-name").get_child().get_text()
846839
         target_type = uiutil.get_list_selection(typebox)
846839
+        clipboard = self.widget("char-vdagent-clipboard").get_active()
846839
 
846839
         if not self.widget("char-path").get_visible():
846839
             source_path = None
846839
@@ -1486,6 +1493,7 @@ class vmmAddHardware(vmmGObjectUI):
846839
         dev.type = devtype
846839
         dev.source.path = source_path
846839
         dev.source.channel = source_channel
846839
+        dev.source.clipboard_copypaste = clipboard
846839
         dev.target_name = target_name
846839
         dev.target_type = target_type
846839
         return dev
846839
diff --git a/virtManager/details/details.py b/virtManager/details/details.py
846839
index 24810f0ff..ddc43b767 100644
846839
--- a/virtManager/details/details.py
846839
+++ b/virtManager/details/details.py
846839
@@ -207,10 +207,10 @@ def _label_for_device(dev, disk_bus_index):
846839
         return _("Console %(num)d") % {"num": port + 1}
846839
 
846839
     if devtype == "channel":
846839
+        pretty_type = vmmAddHardware.char_pretty_type(dev.type)
846839
         name = vmmAddHardware.char_pretty_channel_name(dev.target_name)
846839
         if name:
846839
-            return _("Channel %(name)s") % {"name": name}
846839
-        pretty_type = vmmAddHardware.char_pretty_type(dev.type)
846839
+            return _("Channel %(type)s (%(name)s)") % {"type": pretty_type, "name": name}
846839
         return _("Channel %(type)s") % {"type": pretty_type}
846839
 
846839
     if devtype == "graphics":
846839
@@ -2098,6 +2098,7 @@ class vmmDetails(vmmGObjectUI):
846839
         primary = self.vm.serial_is_console_dup(chardev)
846839
         show_target_type = not (char_type in ["serial", "parallel"])
846839
         is_qemuga = chardev.target_name == chardev.CHANNEL_NAME_QEMUGA
846839
+        show_clipboard = chardev.type == chardev.TYPE_QEMUVDAGENT
846839
 
846839
         if char_type == "serial":
846839
             typelabel = _("Serial Device")
846839
@@ -2152,6 +2153,8 @@ class vmmDetails(vmmGObjectUI):
846839
         # notifiations about connection state. For spice this UI field
846839
         # can get out of date
846839
         show_ui("char-target-state", chardev.target_state, doshow=is_qemuga)
846839
+        clipboard = _("On") if chardev.source.clipboard_copypaste else _("Off")
846839
+        show_ui("char-clipboard-sharing", clipboard, doshow=show_clipboard)
846839
 
846839
     def _refresh_hostdev_page(self, hostdev):
846839
         rom_bar = hostdev.rom_bar
846839
-- 
846839
2.35.3
846839