While doing 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 , 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>
This commit is contained in:
Chris Lalancette 2008-10-21 17:15:53 +00:00
parent e98d8d7997
commit c83c3e9e5c
5 changed files with 12 additions and 4 deletions

View File

@ -1,3 +1,9 @@
Tue Oct 21 19:13:00 CEST 2008 Chris Lalancette <clalance@redhat.com>
* src/qemu_driver.c src/storage_conf.c src/network_driver.c
src/storage_driver.c: Shore up the uses of virGetLastError() so that
if a path forgets to set a virError, we don't crash while trying
to dereference the NULL pointer to print out.
Tue Oct 21 09:19:24 PDT 2008 Dan Smith <danms@us.ibm.com>
* src/cgroup.c src/cgroup.h: Add function to allow major device range
* src/lxc_container.h src/controller.c: Fix cgroup initialization

View File

@ -98,7 +98,8 @@ networkAutostartConfigs(struct network_driver *driver) {
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);
}
}
}

View File

@ -136,7 +136,8 @@ qemudAutostartConfigs(struct qemud_driver *driver) {
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);
}
}
}

View File

@ -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;
}

View File

@ -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);
}