]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: disk: Move validation of disk bus vs disk type
authorPeter Krempa <pkrempa@redhat.com>
Wed, 20 Apr 2016 15:11:52 +0000 (17:11 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 21 Apr 2016 15:04:06 +0000 (17:04 +0200)
src/conf/domain_conf.c

index 8ac308ccc2a583717f56d7f1b74de6bbfd8f0630..f76a8b7f87b4a8d1dde761b3bb865a873485496d 100644 (file)
@@ -6925,6 +6925,22 @@ virDomainDiskDefValidate(const virDomainDiskDef *def)
         }
     }
 
+    if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
+        def->bus != VIR_DOMAIN_DISK_BUS_FDC) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Invalid bus type '%s' for floppy disk"),
+                       virDomainDiskBusTypeToString(def->bus));
+        return -1;
+    }
+
+    if (def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
+        def->bus == VIR_DOMAIN_DISK_BUS_FDC) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Invalid bus type '%s' for disk"),
+                       virDomainDiskBusTypeToString(def->bus));
+        return -1;
+    }
+
     return 0;
 }
 
@@ -7415,19 +7431,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
         }
     }
 
-    if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
-        def->bus != VIR_DOMAIN_DISK_BUS_FDC) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Invalid bus type '%s' for floppy disk"), bus);
-        goto error;
-    }
-    if (def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
-        def->bus == VIR_DOMAIN_DISK_BUS_FDC) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Invalid bus type '%s' for disk"), bus);
-        goto error;
-    }
-
     if (devaddr) {
         if (virDomainParseLegacyDeviceAddress(devaddr,
                                               &def->info.addr.pci) < 0) {