[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 1/5]: Shore up virGetLastError handling



While doing testing on this patch series, I mistakenly added a bogus piece of
storage XML to libvirtd, which was saved in /etc/libvirt/storage.  On subsequent
stop/start of libvirtd, because of another bug (fixed in a later patch), an
error wasn't being set properly in an error path, so libvirtd was SEGV'ing in
storage_conf.c:virStoragePoolObjLoad when trying to dereference the NULL err
returned from virGetLastError().  Make this more robust against errors by always
doing "err ? err->message : NULL" in the printf.  I looked around the tree and
found a couple of other places that weren't guarded, so this patch fixes them as
well.

Signed-off-by: Chris Lalancette <clalance redhat com>
diff -up ./src/qemu_driver.c.orig ./src/qemu_driver.c
--- ./src/qemu_driver.c.orig	2008-10-21 14:42:35.000000000 +0200
+++ ./src/qemu_driver.c	2008-10-21 14:43:05.000000000 +0200
@@ -136,7 +136,8 @@ qemudAutostartConfigs(struct qemud_drive
             qemudStartVMDaemon(NULL, driver, driver->domains.objs[i], NULL) < 0) {
             virErrorPtr err = virGetLastError();
             qemudLog(QEMUD_ERR, _("Failed to autostart VM '%s': %s\n"),
-                     driver->domains.objs[i]->def->name, err->message);
+                     driver->domains.objs[i]->def->name,
+                     err ? err->message : NULL);
         }
     }
 }
diff -up ./src/storage_backend_logical.c.orig ./src/storage_backend_logical.c
diff -up ./src/storage_conf.c.orig ./src/storage_conf.c
--- ./src/storage_conf.c.orig	2008-10-21 14:43:32.000000000 +0200
+++ ./src/storage_conf.c	2008-10-21 14:43:47.000000000 +0200
@@ -1043,7 +1043,7 @@ virStoragePoolObjLoad(virConnectPtr conn
     if (!(def = virStoragePoolDefParse(NULL, xml, file))) {
         virErrorPtr err = virGetLastError();
         virStorageLog("Error parsing storage pool config '%s' : %s",
-                      path, err->message);
+                      path, err ? err->message : NULL);
         return NULL;
     }
 
diff -up ./src/network_driver.c.orig ./src/network_driver.c
--- ./src/network_driver.c.orig	2008-10-21 14:41:43.000000000 +0200
+++ ./src/network_driver.c	2008-10-21 14:42:18.000000000 +0200
@@ -98,7 +98,8 @@ networkAutostartConfigs(struct network_d
             networkStartNetworkDaemon(NULL, driver, driver->networks.objs[i]) < 0) {
             virErrorPtr err = virGetLastError();
             networkLog(NETWORK_ERR, _("Failed to autostart network '%s': %s\n"),
-                       driver->networks.objs[i]->def->name, err->message);
+                       driver->networks.objs[i]->def->name,
+                       err ? err->message : NULL);
         }
     }
 }
diff -up ./src/storage_driver.c.orig ./src/storage_driver.c
--- ./src/storage_driver.c.orig	2008-10-21 14:44:38.000000000 +0200
+++ ./src/storage_driver.c	2008-10-21 14:44:54.000000000 +0200
@@ -232,7 +232,7 @@ storageDriverShutdown(void) {
                 backend->stopPool(NULL, pool) < 0) {
                 virErrorPtr err = virGetLastError();
                 storageLog("Failed to stop storage pool '%s': %s",
-                           pool->def->name, err->message);
+                           pool->def->name, err ? err->message : NULL);
             }
             virStoragePoolObjClearVols(pool);
         }

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]