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.record = []
self._change_state(self.STATE_DISCONNECTED) self._change_state(self.STATE_DISCONNECTED)
def open(self): def open(self, sync=False):
if self.state != self.STATE_DISCONNECTED: if self.state != self.STATE_DISCONNECTED:
return return
self.connectError = None
self._change_state(self.STATE_CONNECTING) self._change_state(self.STATE_CONNECTING)
logging.debug("Scheduling background open thread for " + self.uri) if sync:
self.connectThread = threading.Thread(target = self._open_thread, logging.debug("Opening connection synchronously: %s" % self.uri)
name = "Connect %s" % self.uri) self._open_thread()
self.connectThread.setDaemon(True) else:
self.connectThread.start() 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): def _do_creds_polkit(self, action):
if os.getuid() == 0: 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.") logging.debug("Duplicating connection for async operation.")
newconn = virtManager.connection.vmmConnection(config, uri, is_readonly) newconn = virtManager.connection.vmmConnection(config, uri, is_readonly)
newconn.open() newconn.open(sync=True)
newconn.connectThreadEvent.wait()
if return_conn_class: if return_conn_class:
return newconn return newconn