[virt-tools-list] [PATCH 4/5] virt-manager: connect with openGraphicsFD

Marc-André Lureau marcandre.lureau at redhat.com
Thu Feb 18 16:47:37 UTC 2016


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

This allows to connect to VM without any listening socket.

Furthermore, since it uses unix socket, spice can use virgl locally
with texture sharing. This effectively enables spice-gtk to display
local virgl rendering.

Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
---
 virtManager/console.py    | 2 +-
 virtManager/domain.py     | 3 +++
 virtManager/sshtunnels.py | 7 ++++++-
 virtManager/viewers.py    | 9 +++++++++
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/virtManager/console.py b/virtManager/console.py
index 3a1338e..1080f4a 100644
--- a/virtManager/console.py
+++ b/virtManager/console.py
@@ -621,7 +621,7 @@ class vmmConsolePages(vmmGObjectUI):
             gdevs = self.vm.get_graphics_devices()
             gdev = gdevs and gdevs[0] or None
             if gdev:
-                ginfo = ConnectionInfo(self.vm.conn, gdev)
+                ginfo = ConnectionInfo(self.vm, gdev)
         except Exception, e:
             # We can fail here if VM is destroyed: xen is a bit racy
             # and can't handle domain lookups that soon after
diff --git a/virtManager/domain.py b/virtManager/domain.py
index ab50d5c..33535af 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -1116,6 +1116,9 @@ class vmmDomain(vmmLibvirtObject):
     def open_console(self, devname, stream, flags=0):
         return self._backend.openConsole(devname, stream, flags)
 
+    def open_graphics_fd(self):
+        return self._backend.openGraphicsFD(0)
+
     def refresh_snapshots(self):
         self._snapshot_list = None
 
diff --git a/virtManager/sshtunnels.py b/virtManager/sshtunnels.py
index 03e1738..4fe8c3f 100644
--- a/virtManager/sshtunnels.py
+++ b/virtManager/sshtunnels.py
@@ -32,7 +32,9 @@ class ConnectionInfo(object):
     """
     Holds all the bits needed to make a connection to a graphical console
     """
-    def __init__(self, conn, gdev):
+    def __init__(self, vm, gdev):
+        conn = vm.conn
+        self.vm = vm
         self.gtype      = gdev.type
         self.gport      = gdev.port and str(gdev.port) or None
         self.gsocket    = gdev.socket
@@ -47,6 +49,9 @@ class ConnectionInfo(object):
         if self._connhost == "localhost":
             self._connhost = "127.0.0.1"
 
+    def get_conn_fd(self):
+        return self.vm.open_graphics_fd()
+
     def _is_listen_localhost(self, host=None):
         try:
             return ipaddr.IPNetwork(host or self.gaddr).is_loopback
diff --git a/virtManager/viewers.py b/virtManager/viewers.py
index e285e44..e1b67b6 100644
--- a/virtManager/viewers.py
+++ b/virtManager/viewers.py
@@ -133,6 +133,10 @@ class Viewer(vmmGObject):
     def _open(self):
         if self._ginfo.need_tunnel():
             self._open_fd(self._tunnels.open_new())
+            return
+        connfd = self._ginfo.get_conn_fd()
+        if connfd != -1:
+            self._open_fd(connfd)
         else:
             self._open_host()
 
@@ -545,6 +549,11 @@ class SpiceViewer(Viewer):
         self._tunnels.unlock()
 
     def _channel_open_fd_request(self, channel, tls_ignore):
+        if not self._ginfo.need_tunnel():
+            connfd = self._ginfo.get_conn_fd()
+            channel.open_fd(connfd)
+            return
+
         if not self._tunnels:
             # Can happen if we close the details window and clear self._tunnels
             # while initially connecting to spice and channel FD requests
-- 
2.5.0




More information about the virt-tools-list mailing list