mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Add a auto-retry with exponential backoff to VNC connection, since with auto-console popup we often launch before the VNC daemon has started for the guest
This commit is contained in:
parent
e9decd56cd
commit
820832a007
@ -51,6 +51,8 @@ class vmmConsole(gobject.GObject):
|
|||||||
self.window.get_widget("console-vnc-align").add(self.vncViewer)
|
self.window.get_widget("console-vnc-align").add(self.vncViewer)
|
||||||
self.vncViewer.connect("size-request", self.autosize)
|
self.vncViewer.connect("size-request", self.autosize)
|
||||||
self.vncViewer.show()
|
self.vncViewer.show()
|
||||||
|
self.vncViewerFailures = 0
|
||||||
|
self.vncViewerRetryDelay = 125
|
||||||
|
|
||||||
self.window.get_widget("console-pages").set_show_tabs(False)
|
self.window.get_widget("console-pages").set_show_tabs(False)
|
||||||
|
|
||||||
@ -147,6 +149,10 @@ class vmmConsole(gobject.GObject):
|
|||||||
def _vnc_disconnected(self, src):
|
def _vnc_disconnected(self, src):
|
||||||
self.activate_auth_page()
|
self.activate_auth_page()
|
||||||
|
|
||||||
|
def retry_login(self):
|
||||||
|
self.try_login()
|
||||||
|
return False
|
||||||
|
|
||||||
def try_login(self, src=None):
|
def try_login(self, src=None):
|
||||||
if self.vm.get_id() == 0:
|
if self.vm.get_id() == 0:
|
||||||
return
|
return
|
||||||
@ -158,7 +164,8 @@ class vmmConsole(gobject.GObject):
|
|||||||
logging.debug("No graphics configured in guest")
|
logging.debug("No graphics configured in guest")
|
||||||
return
|
return
|
||||||
|
|
||||||
logging.debug("Graphics " + str(protocol) + "://" + str(host) + ":" + str(port))
|
uri = str(protocol) + "://" + str(host) + ":" + str(port)
|
||||||
|
logging.debug("Graphics console configured at " + uri)
|
||||||
|
|
||||||
if protocol != "vnc":
|
if protocol != "vnc":
|
||||||
self.activate_unavailable_page()
|
self.activate_unavailable_page()
|
||||||
@ -168,10 +175,22 @@ class vmmConsole(gobject.GObject):
|
|||||||
try:
|
try:
|
||||||
self.vncViewer.connect_to_host(host, port)
|
self.vncViewer.connect_to_host(host, port)
|
||||||
except:
|
except:
|
||||||
logging.error("Unable to activate console " + str((sys.exc_info())[0]) + " " + str((sys.exc_info())[1]))
|
self.vncViewerFailures = self.vncViewerFailures + 1
|
||||||
|
logging.warn("Unable to activate console " + uri + ": " + str((sys.exc_info())[0]) + " " + str((sys.exc_info())[1]))
|
||||||
self.activate_unavailable_page()
|
self.activate_unavailable_page()
|
||||||
|
if self.vncViewerFailures < 10:
|
||||||
|
logging.warn("Retrying connection in %d ms", self.vncViewerRetryDelay)
|
||||||
|
gobject.timeout_add(self.vncViewerRetryDelay, self.retry_login)
|
||||||
|
if self.vncViewerRetryDelay < 2000:
|
||||||
|
self.vncViewerRetryDelay = self.vncViewerRetryDelay * 2
|
||||||
|
else:
|
||||||
|
logging.error("Too many connection failures, not retrying again")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Had a succesfull connect, so reset counters now
|
||||||
|
self.vncViewerFailures = 0
|
||||||
|
self.vncViewerRetryDelay = 125
|
||||||
|
|
||||||
if self.vncViewer.is_authenticated():
|
if self.vncViewer.is_authenticated():
|
||||||
self.activate_viewer_page()
|
self.activate_viewer_page()
|
||||||
elif password or not(self.vncViewer.needs_password()):
|
elif password or not(self.vncViewer.needs_password()):
|
||||||
|
@ -24,6 +24,7 @@ import sys
|
|||||||
from struct import pack, unpack
|
from struct import pack, unpack
|
||||||
import pygtk
|
import pygtk
|
||||||
import gtk
|
import gtk
|
||||||
|
import logging
|
||||||
|
|
||||||
stderr = sys.stderr
|
stderr = sys.stderr
|
||||||
|
|
||||||
@ -103,15 +104,14 @@ class GRFBFrameBuffer(rfb.RFBFrameBuffer, gobject.GObject):
|
|||||||
x2 = self.dirtyregion["x2"]
|
x2 = self.dirtyregion["x2"]
|
||||||
y1 = self.dirtyregion["y1"]
|
y1 = self.dirtyregion["y1"]
|
||||||
y2 = self.dirtyregion["y2"]
|
y2 = self.dirtyregion["y2"]
|
||||||
#print "Update %d,%d (%dx%d)" % (x1, y1, (x2-x1), (y2-y1))
|
|
||||||
self.emit("invalidate", x1, y1, x2-x1, y2-y1)
|
self.emit("invalidate", x1, y1, x2-x1, y2-y1)
|
||||||
self.dirtyregion = None
|
self.dirtyregion = None
|
||||||
|
|
||||||
def change_cursor(self, width, height, x, y, data):
|
def change_cursor(self, width, height, x, y, data):
|
||||||
print >>stderr, 'change_cursor'
|
logging.error("Unsupported change_cursor operation requested")
|
||||||
|
|
||||||
def move_cursor(self, x, y):
|
def move_cursor(self, x, y):
|
||||||
print >>stderr, 'move_cursor'
|
logging.error("Unsupported move_cursor operation requested")
|
||||||
|
|
||||||
gobject.type_register(GRFBFrameBuffer)
|
gobject.type_register(GRFBFrameBuffer)
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ class GRFBNetworkClient(rfb.RFBNetworkClient, gobject.GObject):
|
|||||||
try:
|
try:
|
||||||
self.loop1()
|
self.loop1()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print str(e)
|
logging.warn("Failure while handling VNC I/O, closing socket: " + str(e))
|
||||||
self.close()
|
self.close()
|
||||||
self.emit("disconnected")
|
self.emit("disconnected")
|
||||||
return 0
|
return 0
|
||||||
@ -323,8 +323,8 @@ class GRFBViewer(gtk.DrawingArea):
|
|||||||
self.client.setpass(password)
|
self.client.setpass(password)
|
||||||
try:
|
try:
|
||||||
self.client.auth()
|
self.client.auth()
|
||||||
except:
|
except Exception, e:
|
||||||
print str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
|
logging.warn("Failure while authenticating " + str(e))
|
||||||
self.disconnect_from_host()
|
self.disconnect_from_host()
|
||||||
return 0
|
return 0
|
||||||
self.authenticated = True
|
self.authenticated = True
|
||||||
|
Loading…
Reference in New Issue
Block a user