engine: Fix started libvirt daemon requirement

This patch makes virt-manager usable again without systemd (or dbus).
When started without systemd, but with libvirtd properly working,
there was error reported, and virt-manager didn't even try to connect
to the destination.

This patch modifies the behavior in two ways.  When connection is
added with "do_start=False" it will still try to connect, but won't
error out when unsuccessful.  The second modification is that upon
startup, the idle_connect() function will error out only if we failed
starting libvirtd _and_ we couldn't connect to the uri.  So if we
failed starting libvirtd, but could connect, there is no disruption
for the user.
This commit is contained in:
Martin Kletzander 2013-10-16 17:38:37 +02:00
parent 408771004f
commit 2b7aa33887

View File

@ -217,10 +217,10 @@ class vmmEngine(vmmGObject):
# packagekit async dialog has a chance to go away
def idle_connect():
do_start = packageutils.start_libvirtd()
if not do_start:
connected = self.connect_to_uri(tryuri, autoconnect=True, do_start=do_start)
if not connected and do_start:
manager.err.ok(_("Libvirt service must be started"), warnmsg)
self.connect_to_uri(tryuri, autoconnect=True, do_start=do_start)
self.idle_add(idle_connect)
@ -489,6 +489,11 @@ class vmmEngine(vmmGObject):
if do_start:
conn.open()
else:
try:
conn.open()
except:
return None
return conn
except Exception:
logging.exception("Error connecting to %s", uri)