[libvirt] [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. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu_driver.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 95ea882..a9b4850 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -1779,6 +1779,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")) { @@ -1795,14 +1801,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; -- 1.6.0.6

On Wed, Jul 08, 2009 at 05:59:22PM -0400, Cole Robinson wrote:
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.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu_driver.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-)
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Daniel P. Berrange wrote:
On Wed, Jul 08, 2009 at 05:59:22PM -0400, Cole Robinson wrote:
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.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu_driver.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-)
ACK
Pushed now. Thanks, Cole

On Wed, Jul 08, 2009 at 05:59:22PM -0400, Cole Robinson wrote:
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.
ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (3)
-
Cole Robinson
-
Daniel P. Berrange
-
Daniel Veillard