[et-mgmt-tools] [PATCH] use localhost when connecting local VNC guest console

Bernhard Kaindl bk at suse.de
Fri Aug 31 16:44:18 UTC 2007


Hi,
    I tried virt-manager-0.5.0 and one of the new features of 0.5.0,
the support for managing guest on other hosts has resulted in a regession
where in 0.4.0, the destination port for the VNC connect was 127.0.0.1:5900
for the local host, while it is now <hostname>:5900:

--- virt-manager-0.4.0/src/virtManager/domain.py	2007-04-16
+++ virt-manager-0.5.0/src/virtManager/domain.py	2007-08-29
...
@@ -430,16 +446,18 @@
          return os.access(tty, os.R_OK | os.W_OK)

      def get_graphics_console(self):
+        self.xml = None
          type = self.get_xml_string("/domain/devices/graphics/@type")
          port = None
          if type == "vnc":
              port = self.get_xml_string("/domain/devices/graphics[@type='vnc']/@port")
-            if port == None:
-                port = 5900 + self.get_id()
-            else:
+            if port is not None:
                  port = int(port)
-            return [type, "127.0.0.1", port]
-        return [type, None, None]
+
+        transport, username = self.connection.get_transport()
+
+        return [type, self.connection.get_hostname(), port, transport]
+

      def get_disk_devices(self):
          xml = self.get_xml()
...


What resulted in the regession for me was that I was using libvirtd
to manage QEMU guests and this setup didn't bind it's VNC port to
<hostname>:5900, but to 127.0.0.1:5900, where it was expected to be
with virt-manager-0.4.0.

I'd usually not recommend to make the VNC console my guests list
<hostname>:<port> unless it's neccessary and the machine is inside
an secure environment because <hostname> is normally defined to
resolve to the LAN address of the machine and that would make the
VNC console accessible from the LAN in case no firewall is active.

How it securely connect to the VNC console of other hypervisor hosts
is over an insecure network is another issue, but it seems easy to
make the console widget of virt-manager-0.5.0 working with the current
VNC console setup when checking by using 127.0.0.1 for the hostname:

virtManager's console.py uses get_graphics_console(self) to get the
directions for connecting to the graphics_console of the guest, so
as far as I tested yet, that is fixed by checking if

self.connection.get_hostname()

 	equals

self.connection.get_local_hostname():

and if that is so (both are the hostname of the local machine) then
the VNC connection can be directed to 127.0.0.1 as before:

--- virt-manager--devel/src/virtManager/domain.py
+++ virt-manager--devel/src/virtManager/domain.py
@@ -456,7 +456,12 @@ def get_graphics_console(self):

          transport, username = self.connection.get_transport()

-        return [type, self.connection.get_hostname(), port, transport]
+        hostname = self.connection.get_hostname()
+
+        if hostname == self.connection.get_local_hostname():
+            hostname = "127.0.0.1"
+
+        return [type, hostname, port, transport]


      def get_disk_devices(self):

Comments?

--
Bernhard Kaindl




More information about the et-mgmt-tools mailing list