From fe7cb869a8bb7d0d45913056b7962283c6c33183 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 8 Jul 2009 17:59:22 -0400 Subject: [PATCH] qemu: Check driver is initialized up front, to avoid segfault. 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 | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/qemu_driver.c b/src/qemu_driver.c index d36dfb357b..e2b7acb9a8 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -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;