]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
conf: Report sensible error for invalid disk name
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 20 Nov 2012 13:45:56 +0000 (14:45 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 22 Nov 2012 14:23:40 +0000 (15:23 +0100)
The error "... but the cause is unknown" appeared for XMLs similar to
this:

 <disk type='file' device='cdrom'>
   <driver name='qemu' type='raw'/>
   <source file='/dev/zero'/>
   <target dev='sr0'/>
 </disk>

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.

src/conf/domain_conf.c
src/qemu/qemu_command.c

index 047c4fc98be85c4a6411b3d3cbfd2e162cc0edf7..ed8b53f81e471ede22c607ee1c0425a1c2b3bce9 100644 (file)
@@ -3055,8 +3055,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:
index 02e105d9c989249ec58ec952b878e0d167fd2ced..9c9a0ed7e8840146217c98fce02d35866eeeb152 100644 (file)
@@ -8381,8 +8381,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;