Blob Blame Raw
From b8d61f6602f82b6e90199d9ce430f9eebb1c894a Mon Sep 17 00:00:00 2001
From: Cole Robinson <crobinso@redhat.com>
Date: Sun, 28 Oct 2012 20:18:51 -0400
Subject: [PATCH] Fix detection of running libvirtd via systemd (cherry picked
 from commit 2163ba3a3035ea8fccd5113d53d120801ba12040)

---
 src/virtManager/engine.py       | 6 ++++--
 src/virtManager/packageutils.py | 5 ++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/virtManager/engine.py b/src/virtManager/engine.py
index 337fc67..2ec455b 100644
--- a/src/virtManager/engine.py
+++ b/src/virtManager/engine.py
@@ -178,8 +178,11 @@ class vmmEngine(vmmGObject):
             manager.set_startup_error(msg)
             return
 
+        do_start = not did_install_libvirt
         if did_install_libvirt:
             didstart = packageutils.start_libvirtd()
+            do_start = didstart
+
             warnmsg = _(
                 "Libvirt was just installed, so the 'libvirtd' service will\n"
                 "will need to be started.\n"
@@ -189,8 +192,7 @@ class vmmEngine(vmmGObject):
             if not didstart:
                 self.err.ok(_("Libvirt service must be started"), warnmsg)
 
-        self.connect_to_uri(tryuri, autoconnect=True,
-                            do_start=not did_install_libvirt)
+        self.connect_to_uri(tryuri, autoconnect=True, do_start=do_start)
 
 
     def load_stored_uris(self):
diff --git a/src/virtManager/packageutils.py b/src/virtManager/packageutils.py
index 736b98c..63cf2b5 100644
--- a/src/virtManager/packageutils.py
+++ b/src/virtManager/packageutils.py
@@ -217,7 +217,7 @@ def start_libvirtd():
         state = props.Get("org.freedesktop.systemd1.Unit", "ActiveState")
 
         logging.debug("libvirtd state=%s", state)
-        if state == "Active":
+        if str(state).lower() == "active":
             logging.debug("libvirtd already active, not starting")
             return True
     except:
@@ -226,12 +226,15 @@ def start_libvirtd():
 
     # Connect to system-config-services and offer to start
     try:
+        logging.debug("libvirtd not running, asking system-config-services "
+                      "to start it")
         scs = dbus.Interface(bus.get_object(
                              "org.fedoraproject.Config.Services",
                              "/org/fedoraproject/Config/Services/systemd1"),
                              "org.freedesktop.systemd1.Manager")
         scs.StartUnit(unitname, "replace")
         time.sleep(2)
+        logging.debug("Starting libvirtd appeared to succeed")
         return True
     except:
         logging.exception("Failed to talk to system-config-services")
-- 
1.7.12.1