[et-mgmt-tools] [PATCH] waiting VNC port number

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

 



Hi,

I try to install with virt-install and sometimes vncviewer get an error 
message that says "unable to connect to host:Connection refused(111)".
So, I cannot continue installation.

The attached patch to resolve this issues in the following way:

  1) Check whether the domain has VNCport number.
  2) If the number is exist, use the VNCport number.
  3) If not, check again every 0.25 second up to 40 seconds.

Signed-off-by: Saori Fukuta <fukuta.saori@xxxxxxxxxxxxxx>

Thanks,
Saori Fukuta.

Index: virt-install (python-virtinst-0.100.0)
===================================================================
--- virt-install        2007-02-19 16:09:12.000000000 +0900
+++ virt-install.new    2007-02-19 16:12:05.000000000 +0900
@@ -306,11 +306,22 @@ def get_xml_string(dom, path):
         return None

 def vnc_console(dom):
-    import time; time.sleep(2) # FIXME: ugh.
-    vncport = get_xml_string(dom,
-                             "/domain/devices/graphics[@type='vnc']/@port")
+    import time
+    import commands
+    num = 0
+    vncport = None
+    cmd = "/usr/bin/xenstore-read /local/domain/%s/console/vnc-port" %(dom.ID())
+    while num < ( 40 / 0.25 ): # 40 seconds, .25 second sleeps
+        ( ret, port ) = commands.getstatusoutput( cmd )
+        if ret == 0:
+            vncport = port
+            break
+        else:
+            num += 1
+            time.sleep(0.25)
     if vncport == None:
-        vncport = 5900 + dom.ID()
+        print >> sys.stderr, "Unable to connect to graphical console; vncport number is not found."
+        return None
     vncport = int(vncport)
     vnchost = "localhost"
     if not os.path.exists("/usr/bin/vncviewer"):




[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux