Fix connection duping for old libvirt versions

This commit is contained in:
Cole Robinson 2010-11-29 18:00:35 -05:00
parent 0a81c82c44
commit f7d428caac
2 changed files with 12 additions and 8 deletions

View File

@ -837,17 +837,22 @@ class vmmConnection(gobject.GObject):
self.record = []
self._change_state(self.STATE_DISCONNECTED)
def open(self):
def open(self, sync=False):
if self.state != self.STATE_DISCONNECTED:
return
self.connectError = None
self._change_state(self.STATE_CONNECTING)
logging.debug("Scheduling background open thread for " + self.uri)
self.connectThread = threading.Thread(target = self._open_thread,
name = "Connect %s" % self.uri)
self.connectThread.setDaemon(True)
self.connectThread.start()
if sync:
logging.debug("Opening connection synchronously: %s" % self.uri)
self._open_thread()
else:
logging.debug("Scheduling background open thread for " + self.uri)
self.connectThread = threading.Thread(target = self._open_thread,
name = "Connect %s" % self.uri)
self.connectThread.setDaemon(True)
self.connectThread.start()
def _do_creds_polkit(self, action):
if os.getuid() == 0:

View File

@ -266,8 +266,7 @@ def _dup_all_conn(config, conn, libconn, return_conn_class):
logging.debug("Duplicating connection for async operation.")
newconn = virtManager.connection.vmmConnection(config, uri, is_readonly)
newconn.open()
newconn.connectThreadEvent.wait()
newconn.open(sync=True)
if return_conn_class:
return newconn