[v2 2/3] virt-manager: Add redirected devices details

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

 



---
 src/virtManager/details.py   |   28 ++++++++++++-
 src/virtManager/uihelpers.py |   19 +++++++++
 src/vmm-details.glade        |   89 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 134 insertions(+), 2 deletions(-)

diff --git a/src/virtManager/details.py b/src/virtManager/details.py
index fd6cc3a..1ee17ff 100644
--- a/src/virtManager/details.py
+++ b/src/virtManager/details.py
@@ -186,6 +186,7 @@ def build_hostdev_label(hostdev):
     addrslt = hostdev.slot
     addrfun = hostdev.function
     addrdom = hostdev.domain
+    redirection = hostdev.redirection
 
     def dehex(val):
         if val.startswith("0x"):
@@ -195,7 +196,17 @@ def build_hostdev_label(hostdev):
     hwlabel = typ.upper()
     srclabel = typ.upper()
 
-    if vendor and product:
+    if redirection:
+        if redirection == 'spicevmc':
+            srclabel += _(" redirected to SPICE client")
+        elif hostdev.host and hostdev.service:
+            srclabel += _(" redirected to %s:%s") % (hostdev.host, hostdev.service)
+        else:
+            raise RuntimeError("unhandled redirection kind: %s" % redirection)
+
+        hwlabel += _(" redirected")
+
+    elif vendor and product:
         # USB by vendor + product
         devstr = " %s:%s" % (dehex(vendor), dehex(product))
         srclabel += devstr
@@ -913,6 +924,10 @@ class vmmDetails(vmmGObjectUI):
         sc_mode = self.widget("smartcard-mode-combo")
         uihelpers.build_smartcard_mode_combo(self.vm, sc_mode)
 
+        # Hostdev/redir mode
+        combo = self.widget("hostdev-mode-combo")
+        uihelpers.build_usbredir_mode_combo(self.vm, combo)
+
     # Helper function to handle the combo/label pattern used for
     # video model, sound model, network model, etc.
     def set_combo_label(self, prefix, value, model_idx=0, label="",
@@ -2967,6 +2982,7 @@ class vmmDetails(vmmGObjectUI):
             return
 
         devtype = hostdev.type
+        redirection = hostdev.redirection
         pretty_name = None
         nodedev = lookup_nodedev(self.vm.conn, hostdev)
         if nodedev:
@@ -2975,10 +2991,18 @@ class vmmDetails(vmmGObjectUI):
         if not pretty_name:
             pretty_name = build_hostdev_label(hostdev)[0] or "-"
 
-        devlabel = "<b>Physical %s Device</b>" % devtype.upper()
+        if hostdev.redirection:
+            devlabel = "<b>Redirected %s Device</b>" % devtype.upper()
+        else:
+            devlabel = "<b>Physical %s Device</b>" % devtype.upper()
         self.widget("hostdev-title").set_markup(devlabel)
         self.widget("hostdev-source").set_text(pretty_name)
 
+        self.set_combo_label("hostdev-mode", redirection)
+        # TODO: let's not make it configurable for now
+        self.widget("hostdev-mode-title").hide()
+        self.widget("hostdev-mode-box").hide()
+
     def refresh_video_page(self):
         vid = self.get_hw_selection(HW_LIST_COL_DEVICE)
         if not vid:
diff --git a/src/virtManager/uihelpers.py b/src/virtManager/uihelpers.py
index 82f1f27..af2916f 100644
--- a/src/virtManager/uihelpers.py
+++ b/src/virtManager/uihelpers.py
@@ -270,6 +270,25 @@ def populate_smartcard_mode_combo(vm, combo):
 # TODO
 #    model.append(["host-certificates", "Host Certificates"])
 
+def build_usbredir_mode_combo(vm, combo):
+    source_mode = gtk.ListStore(str, str, bool)
+    combo.set_model(source_mode)
+    text = gtk.CellRendererText()
+    combo.pack_start(text, True)
+    combo.add_attribute(text, 'text', 1)
+
+    populate_usbredir_mode_combo(vm, combo)
+    combo.set_active(0)
+
+def populate_usbredir_mode_combo(vm, combo):
+    ignore = vm
+    model = combo.get_model()
+    model.clear()
+
+    # [xml value, label, conn details]
+    model.append(["spicevmc", "Spice channel", False])
+    model.append(["tcp", "TCP", True])
+
 def build_netmodel_combo(vm, combo):
     dev_model = gtk.ListStore(str, str)
     combo.set_model(dev_model)
diff --git a/src/vmm-details.glade b/src/vmm-details.glade
index 8ab386b..62b741b 100644
--- a/src/vmm-details.glade
+++ b/src/vmm-details.glade
@@ -5170,6 +5170,7 @@ I/O:</property>
                                         <child>
                                           <widget class="GtkTable" id="table50">
                                             <property name="visible">True</property>
+                                            <property name="n_rows">2</property>
                                             <property name="n_columns">2</property>
                                             <property name="column_spacing">8</property>
                                             <property name="row_spacing">4</property>
@@ -5180,6 +5181,8 @@ I/O:</property>
                                                 <property name="label" translatable="yes">Device:</property>
                                               </widget>
                                               <packing>
+                                                <property name="top_attach">1</property>
+                                                <property name="bottom_attach">2</property>
                                                 <property name="x_options">GTK_FILL</property>
                                                 <property name="y_options"></property>
                                               </packing>
@@ -5192,12 +5195,98 @@ I/O:</property>
                                                 <property name="selectable">True</property>
                                               </widget>
                                               <packing>
+                                                <property name="top_attach">1</property>
+                                                <property name="bottom_attach">2</property>
                                                 <property name="left_attach">1</property>
                                                 <property name="right_attach">2</property>
                                                 <property name="x_options">GTK_FILL</property>
                                                 <property name="y_options"></property>
                                               </packing>
                                             </child>
+
+                                            <child>
+                                              <widget class="GtkLabel" id="hostdev-mode-title">
+                                                <property name="visible">True</property>
+                                                <property name="label" translatable="yes">Mode:</property>
+                                                <property name="use_underline">False</property>
+                                                <property name="use_markup">False</property>
+                                                <property name="justify">GTK_JUSTIFY_LEFT</property>
+                                                <property name="wrap">False</property>
+                                                <property name="selectable">False</property>
+                                                <property name="xalign">0</property>
+                                                <property name="yalign">0.5</property>
+                                                <property name="xpad">0</property>
+                                                <property name="ypad">0</property>
+                                                <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+                                                <property name="width_chars">-1</property>
+                                                <property name="single_line_mode">False</property>
+                                                <property name="angle">0</property>
+                                              </widget>
+                                              <packing>
+                                                <property name="left_attach">0</property>
+                                                <property name="right_attach">1</property>
+                                                <property name="top_attach">0</property>
+                                                <property name="bottom_attach">1</property>
+                                                <property name="x_options">fill</property>
+                                                <property name="y_options"></property>
+                                              </packing>
+                                            </child>
+
+                                            <child>
+                                              <widget class="GtkHBox" id="hostdev-mode-box">
+                                                <property name="visible">True</property>
+                                                <property name="homogeneous">False</property>
+                                                <property name="spacing">0</property>
+
+                                                <child>
+                                                  <widget class="GtkComboBox" id="hostdev-mode-combo">
+                                                    <property name="visible">True</property>
+                                                    <property name="add_tearoffs">False</property>
+                                                    <property name="focus_on_click">True</property>
+                                                    <signal name="changed" handler="on_gfx_type_combo_changed"/>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="padding">0</property>
+                                                    <property name="expand">False</property>
+                                                    <property name="fill">True</property>
+                                                  </packing>
+                                                </child>
+
+                                                <child>
+                                                  <widget class="GtkLabel" id="hostdev-mode-label">
+                                                    <property name="visible">True</property>
+                                                    <property name="label" translatable="yes">label</property>
+                                                    <property name="use_underline">False</property>
+                                                    <property name="use_markup">False</property>
+                                                    <property name="justify">GTK_JUSTIFY_LEFT</property>
+                                                    <property name="wrap">False</property>
+                                                    <property name="selectable">False</property>
+                                                    <property name="xalign">0</property>
+                                                    <property name="yalign">0.5</property>
+                                                    <property name="xpad">0</property>
+                                                    <property name="ypad">0</property>
+                                                    <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+                                                    <property name="width_chars">-1</property>
+                                                    <property name="single_line_mode">False</property>
+                                                    <property name="angle">0</property>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="padding">0</property>
+                                                    <property name="expand">False</property>
+                                                    <property name="fill">True</property>
+                                                  </packing>
+                                                </child>
+                                              </widget>
+                                              <packing>
+                                                <property name="left_attach">1</property>
+                                                <property name="right_attach">2</property>
+                                                <property name="top_attach">0</property>
+                                                <property name="bottom_attach">1</property>
+                                                <property name="x_options">fill</property>
+                                                <property name="y_options">fill</property>
+                                              </packing>
+                                            </child>
+
                                           </widget>
                                         </child>
                                       </widget>
-- 
1.7.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[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]