[libvirt] [PATCH 12/14] conf: disk: Move validation of disk bus vs disk type

Peter Krempa pkrempa at redhat.com
Wed Apr 20 15:58:22 UTC 2016


---
 src/conf/domain_conf.c | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5fd8cc4..baf6f84 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6933,6 +6933,22 @@ virDomainDiskDefValidate(const virDomainDiskDef *def)
         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 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;
 }

@@ -7416,19 +7432,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) {
-- 
2.8.1




More information about the libvir-list mailing list