[Libvir] [PATCH] add missing qemudReportError

Hi, without this qemudParseVMDef might return NULL when the boot dev configuration is invalid but virGetLastError returns NULL either since no error has been set, this leads to a segfault in qemudLoadConfig when trying to print the error message. Cheers, -- Guido diff --git a/src/qemu_conf.c b/src/qemu_conf.c index 6dc08e0..48ccc60 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -1193,6 +1193,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn, } else if (!strcmp((char *)prop, "network")) { def->os.bootDevs[def->os.nBootDevs++] = QEMUD_BOOT_NET; } else { + qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "unknown boot dev \'%s\'", (char*)prop); goto error; } xmlFree(prop);

without this qemudParseVMDef might return NULL when the boot dev configuration is invalid but virGetLastError returns NULL either since no error has been set, this leads to a segfault in qemudLoadConfig when trying to print the error message. That said it might also be worthwhile to not let libvirtd segfault because of a missing call to qemudReportError - this is debatable
On Tue, Feb 05, 2008 at 01:06:14PM +0100, Guido Guenther wrote: though: -- Guido diff --git a/src/qemu_conf.c b/src/qemu_conf.c index 48ccc60..bed5bf7 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -2524,7 +2525,7 @@ qemudLoadConfig(struct qemud_driver *driver, if (!(def = qemudParseVMDef(NULL, driver, xml, file))) { virErrorPtr err = virGetLastError(); qemudLog(QEMUD_WARN, "Error parsing QEMU guest config '%s' : %s", - path, err->message); + path, err ? err->message : "BUG: unknown error - please report\n"); return NULL; }

On Tue, Feb 05, 2008 at 01:09:15PM +0100, Guido Guenther wrote:
without this qemudParseVMDef might return NULL when the boot dev configuration is invalid but virGetLastError returns NULL either since no error has been set, this leads to a segfault in qemudLoadConfig when trying to print the error message. That said it might also be worthwhile to not let libvirtd segfault because of a missing call to qemudReportError - this is debatable
On Tue, Feb 05, 2008 at 01:06:14PM +0100, Guido Guenther wrote: though:
ACK to both patches. Any & all scenarios which can cause a crash must be fixed. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

I just noticed that the patch got mangled, sorry: On Tue, Feb 05, 2008 at 01:09:15PM +0100, Guido Guenther wrote:
That said it might also be worthwhile to not let libvirtd segfault because of a missing call to qemudReportError - this is debatable though:
diff --git a/src/qemu_conf.c b/src/qemu_conf.c index 6e4f39c..e382afa 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -2524,7 +2524,7 @@ qemudLoadConfig(struct qemud_driver *driver, if (!(def = qemudParseVMDef(NULL, driver, xml, file))) { virErrorPtr err = virGetLastError(); qemudLog(QEMUD_WARN, "Error parsing QEMU guest config '%s' : %s", - path, err->message); + path, err ? err->message : "BUG: unknown error - please report\n"); return NULL; }

On Wed, Feb 06, 2008 at 03:23:50PM +0100, Guido Guenther wrote:
I just noticed that the patch got mangled, sorry: On Tue, Feb 05, 2008 at 01:09:15PM +0100, Guido Guenther wrote:
That said it might also be worthwhile to not let libvirtd segfault because of a missing call to qemudReportError - this is debatable though:
diff --git a/src/qemu_conf.c b/src/qemu_conf.c index 6e4f39c..e382afa 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -2524,7 +2524,7 @@ qemudLoadConfig(struct qemud_driver *driver, if (!(def = qemudParseVMDef(NULL, driver, xml, file))) { virErrorPtr err = virGetLastError(); qemudLog(QEMUD_WARN, "Error parsing QEMU guest config '%s' : %s", - path, err->message); + path, err ? err->message : "BUG: unknown error - please report\n"); return NULL; }
Okay, I have applied both patches, which just a bit of reformating, thanks ! Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Guido Guenther