From: Martin Kletzander Date: Tue, 20 Nov 2012 13:45:56 +0000 (+0100) Subject: conf: Report sensible error for invalid disk name X-Git-Tag: v0.10.2.2~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=179216680ed2a02053983f31c374ef55489b9f5a;p=thirdparty%2Flibvirt.git conf: Report sensible error for invalid disk name The error "... but the cause is unknown" appeared for XMLs similar to this: Notice unsupported disk type (for the driver), but also no address specified. The first part is not a problem and we should not abort immediately because of that, but the combination with the address unknown was causing an unspecified error. While fixing this, I added an error to one place where this return value was not managed properly. (cherry picked from commit 03cd6e4ae8d86682986249f05f7de8eb405a12da) --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 242fec8f84..c64d7ffcf3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2999,8 +2999,12 @@ int virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def) { int idx = virDiskNameToIndex(def->dst); - if (idx < 0) + if (idx < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Unknown disk name '%s' and no address specified"), + def->dst); return -1; + } switch (def->bus) { case VIR_DOMAIN_DISK_BUS_SCSI: diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 13e1c6fd33..af1ff3ea13 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8299,8 +8299,12 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, !disk->dst) goto no_memory; - if (virDomainDiskDefAssignAddress(caps, disk) < 0) + if (virDomainDiskDefAssignAddress(caps, disk) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot assign address for device name '%s'"), + disk->dst); goto error; + } if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0) goto no_memory;