]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Check driver is initialized up front, to avoid segfault.
authorCole Robinson <crobinso@redhat.com>
Wed, 8 Jul 2009 21:59:22 +0000 (17:59 -0400)
committerCole Robinson <crobinso@redhat.com>
Fri, 10 Jul 2009 23:29:31 +0000 (19:29 -0400)
If the qemu_driver was not initialized (possibly due to an error on driver
startup), we can segfault if attempting to connect to the URI.

src/qemu_driver.c

index d36dfb357b3b61c22b8039f0ea1631b927bc9588..e2b7acb9a88a69c8aced46c0bea6ec612e543c60 100644 (file)
@@ -1867,6 +1867,12 @@ static virDrvOpenStatus qemudOpen(virConnectPtr conn,
         if (conn->uri->server != NULL)
             return VIR_DRV_OPEN_DECLINED;
 
+        if (qemu_driver == NULL) {
+            qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+                             _("qemu state driver is not active"));
+            return VIR_DRV_OPEN_ERROR;
+        }
+
         if (qemu_driver->privileged) {
             if (STRNEQ (conn->uri->path, "/system") &&
                 STRNEQ (conn->uri->path, "/session")) {
@@ -1883,14 +1889,6 @@ static virDrvOpenStatus qemudOpen(virConnectPtr conn,
                 return VIR_DRV_OPEN_ERROR;
             }
         }
-
-        /* URI was good, but driver isn't active */
-        if (qemu_driver == NULL) {
-            qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
-                             _("qemu state driver is not active"));
-            return VIR_DRV_OPEN_ERROR;
-        }
-
     }
     conn->privateData = qemu_driver;