[virt-tools-list] [PATCH 11/12] virtManager/ui: add rendernode selection

marcandre.lureau at redhat.com marcandre.lureau at redhat.com
Tue Feb 21 13:01:01 UTC 2017


From: Marc-André Lureau <marcandre.lureau at redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
 ui/gfxdetails.ui           | 35 +++++++++++++++++++++++++++++++++++
 virtManager/addhardware.py |  3 ++-
 virtManager/details.py     |  9 +++++++--
 virtManager/domain.py      |  4 +++-
 virtManager/gfxdetails.py  | 34 +++++++++++++++++++++++++++++++---
 5 files changed, 78 insertions(+), 7 deletions(-)

diff --git a/ui/gfxdetails.ui b/ui/gfxdetails.ui
index 9e3b6cd3..ca719bb7 100644
--- a/ui/gfxdetails.ui
+++ b/ui/gfxdetails.ui
@@ -425,5 +425,40 @@
         <property name="top_attach">1</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkLabel" id="label5">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">GPU:</property>
+        <property name="use_underline">True</property>
+        <property name="mnemonic_widget">graphics-rendernode</property>
+        <property name="xalign">1</property>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">10</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkComboBox" id="graphics-rendernode">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="halign">start</property>
+        <property name="hexpand">False</property>
+        <property name="has_entry">True</property>
+        <signal name="changed" handler="on_graphics_rendernode_changed" swapped="no"/>
+        <child internal-child="entry">
+          <object class="GtkEntry">
+            <property name="can_focus">True</property>
+            <property name="halign">start</property>
+            <property name="editable">True</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">1</property>
+        <property name="top_attach">10</property>
+      </packing>
+    </child>
   </object>
 </interface>
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 8d6c815a..7645cf97 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1555,12 +1555,13 @@ class vmmAddHardware(vmmGObjectUI):
     def _validate_page_graphics(self):
         try:
             (gtype, port, tlsport, listen,
-             addr, passwd, keymap, gl) = self._gfxdetails.get_values()
+             addr, passwd, keymap, gl, rendernode) = self._gfxdetails.get_values()
 
             self._dev = virtinst.VirtualGraphics(self.conn.get_backend())
             self._dev.type = gtype
             self._dev.passwd = passwd
             self._dev.gl = gl
+            self._dev.rendernode = rendernode
 
             if not listen or listen == "none":
                 self._dev.set_listen_none()
diff --git a/virtManager/details.py b/virtManager/details.py
index 2e6f413c..3e37a12c 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -92,6 +92,7 @@ EDIT_GFX_ADDRESS,
 EDIT_GFX_TLSPORT,
 EDIT_GFX_PORT,
 EDIT_GFX_OPENGL,
+EDIT_GFX_RENDERNODE,
 
 EDIT_VIDEO_MODEL,
 
@@ -106,7 +107,7 @@ EDIT_FS,
 
 EDIT_HOSTDEV_ROMBAR,
 
-) = range(1, 47)
+) = range(1, 48)
 
 
 # Columns in hw list model
@@ -397,6 +398,8 @@ class vmmDetails(vmmGObjectUI):
             lambda *x: self.enable_apply(x, EDIT_GFX_PORT))
         self.gfxdetails.connect("changed-opengl",
             lambda *x: self.enable_apply(x, EDIT_GFX_OPENGL))
+        self.gfxdetails.connect("changed-rendernode",
+            lambda *x: self.enable_apply(x, EDIT_GFX_RENDERNODE))
         self.gfxdetails.connect("changed-tlsport",
             lambda *x: self.enable_apply(x, EDIT_GFX_TLSPORT))
         self.gfxdetails.connect("changed-listen",
@@ -2156,7 +2159,7 @@ class vmmDetails(vmmGObjectUI):
 
     def config_graphics_apply(self, devobj):
         (gtype, port, tlsport, listen,
-         addr, passwd, keymap, gl) = self.gfxdetails.get_values()
+         addr, passwd, keymap, gl, rendernode) = self.gfxdetails.get_values()
 
         kwargs = {}
 
@@ -2174,6 +2177,8 @@ class vmmDetails(vmmGObjectUI):
             kwargs["gl"] = gl
         if self.edited(EDIT_GFX_TLSPORT) or self.edited(EDIT_GFX_LISTEN):
             kwargs["tlsport"] = tlsport
+        if self.edited(EDIT_GFX_RENDERNODE):
+            kwargs["rendernode"] = rendernode
         if self.edited(EDIT_GFX_TYPE):
             kwargs["gtype"] = gtype
 
diff --git a/virtManager/domain.py b/virtManager/domain.py
index 23585e4d..58580861 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -826,7 +826,7 @@ class vmmDomain(vmmLibvirtObject):
     def define_graphics(self, devobj, do_hotplug,
         listen=_SENTINEL, addr=_SENTINEL, port=_SENTINEL, tlsport=_SENTINEL,
         passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL,
-        gl=_SENTINEL):
+        gl=_SENTINEL, rendernode=_SENTINEL):
         xmlobj = self._make_xmlobj_to_define()
         editdev = self._lookup_device_to_define(xmlobj, devobj, do_hotplug)
         if not editdev:
@@ -846,6 +846,8 @@ class vmmDomain(vmmLibvirtObject):
             editdev.type = gtype
         if gl != _SENTINEL:
             editdev.gl = gl
+        if rendernode != _SENTINEL:
+            editdev.rendernode = rendernode
         if listen != _SENTINEL:
             listentype = editdev.get_first_listen_type()
             if listen == 'none':
diff --git a/virtManager/gfxdetails.py b/virtManager/gfxdetails.py
index fa3d9ea6..b96dbd9c 100644
--- a/virtManager/gfxdetails.py
+++ b/virtManager/gfxdetails.py
@@ -37,6 +37,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
         "changed-address": (GObject.SignalFlags.RUN_FIRST, None, []),
         "changed-keymap": (GObject.SignalFlags.RUN_FIRST, None, []),
         "changed-opengl": (GObject.SignalFlags.RUN_FIRST, None, []),
+        "changed-rendernode": (GObject.SignalFlags.RUN_FIRST, None, []),
     }
 
     def __init__(self, vm, builder, topwin):
@@ -57,7 +58,8 @@ class vmmGraphicsDetails(vmmGObjectUI):
             "on_graphics_tlsport_changed": lambda ignore: self.emit("changed-tlsport"),
             "on_graphics_port_changed": lambda ignore: self.emit("changed-port"),
             "on_graphics_keymap_changed": lambda ignore: self.emit("changed-keymap"),
-            "on_graphics_opengl_toggled": lambda ignore: self.emit("changed-opengl"),
+            "on_graphics_opengl_toggled": self._change_opengl,
+            "on_graphics_rendernode_changed": lambda ignore: self.emit("changed-rendernode")
         })
 
         self._init_ui()
@@ -109,6 +111,21 @@ class vmmGraphicsDetails(vmmGObjectUI):
         for k in virtinst.VirtualGraphics.valid_keymaps():
             model.append([k, k])
 
+        # Host GPU rendernode
+        combo = self.widget("graphics-rendernode")
+        model = Gtk.ListStore(str, str)
+        combo.set_model(model)
+        uiutil.init_combo_text_column(combo, 1)
+        model.append([None, _("Auto")])
+        devs = self.conn.filter_nodedevs("drm")
+        for i in devs:
+            drm = i.xmlobj
+            if drm.drm_type != 'render':
+                continue
+            rendernode = drm.get_devnode().path
+
+            model.append([rendernode, i.xmlobj.drm_pretty_name(self.conn.get_backend())])
+
     def _get_config_graphics_ports(self):
         port = uiutil.spin_get_helper(self.widget("graphics-port"))
         tlsport = uiutil.spin_get_helper(self.widget("graphics-tlsport"))
@@ -136,6 +153,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
         self.widget("graphics-listen-type").set_active(0)
         self.widget("graphics-address").set_active(0)
         self.widget("graphics-keymap").set_active(0)
+        self.widget("graphics-rendernode").set_active(0)
 
         self._change_ports()
         self.widget("graphics-port-auto").set_active(True)
@@ -158,8 +176,9 @@ class vmmGraphicsDetails(vmmGObjectUI):
             passwd = None
 
         gl = self.widget("graphics-opengl").get_active()
+        rendernode = uiutil.get_list_selection(self.widget("graphics-rendernode"))
 
-        return gtype, port, tlsport, listen, addr, passwd, keymap, gl
+        return gtype, port, tlsport, listen, addr, passwd, keymap, gl, rendernode
 
     def set_dev(self, gfx):
         self.reset_state()
@@ -210,6 +229,8 @@ class vmmGraphicsDetails(vmmGObjectUI):
         if is_spice:
             set_port("graphics-tlsport", gfx.tlsPort)
             self.widget("graphics-opengl").set_active(gfx.gl or False)
+            uiutil.set_list_selection(
+                self.widget("graphics-rendernode"), gfx.rendernode or None)
 
         if is_sdl:
             title = _("Local SDL Window")
@@ -230,7 +251,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
     def _show_rows_from_type(self):
         hide_all = ["graphics-xauth", "graphics-display", "graphics-address",
             "graphics-password-box", "graphics-keymap", "graphics-port-box",
-            "graphics-tlsport-box", "graphics-opengl"]
+            "graphics-tlsport-box", "graphics-opengl", "graphics-rendernode"]
 
         gtype = uiutil.get_list_selection(self.widget("graphics-type"))
         listen = uiutil.get_list_selection(self.widget("graphics-listen-type"))
@@ -244,6 +265,9 @@ class vmmGraphicsDetails(vmmGObjectUI):
             spice_rows.extend(["graphics-tlsport-box"])
         if self.conn.check_support(self.conn.SUPPORT_CONN_SPICE_GL):
             spice_rows.extend(["graphics-opengl"])
+            gl = self.widget("graphics-opengl").get_active()
+            if gl and self.conn.check_support(self.conn.SUPPORT_CONN_SPICE_RENDERNODE):
+                spice_rows.extend(["graphics-rendernode"])
 
         rows = []
         if gtype == "sdl":
@@ -264,6 +288,10 @@ class vmmGraphicsDetails(vmmGObjectUI):
         self._show_rows_from_type()
         self.emit("changed-listen")
 
+    def _change_opengl(self, ignore):
+        self._show_rows_from_type()
+        self.emit("changed-opengl")
+
     def _change_port_auto(self, ignore):
         self.widget("graphics-port-auto").set_inconsistent(False)
         self._change_ports()
-- 
2.11.0.295.gd7dffce1c.dirty




More information about the virt-tools-list mailing list