]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: disk: extract sgio/rawio validation
authorPeter Krempa <pkrempa@redhat.com>
Wed, 20 Apr 2016 14:52:46 +0000 (16:52 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 21 Apr 2016 15:04:06 +0000 (17:04 +0200)
src/conf/domain_conf.c

index b1432ef03277f96fd3fb9ddd15cbbfb307e3b515..8ac308ccc2a583717f56d7f1b74de6bbfd8f0630 100644 (file)
@@ -6911,6 +6911,20 @@ virDomainDiskDefValidate(const virDomainDiskDef *def)
         }
     }
 
+    if (def->device != VIR_DOMAIN_DISK_DEVICE_LUN) {
+        if (def->rawio != VIR_TRISTATE_BOOL_ABSENT) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("rawio can be used only with device='lun'"));
+            return -1;
+        }
+
+        if (def->sgio != VIR_DOMAIN_DEVICE_SGIO_DEFAULT) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("sgio can be used only with device='lun'"));
+            return -1;
+        }
+    }
+
     return 0;
 }
 
@@ -7330,14 +7344,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
         def->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_NONE;
     }
 
-    if ((rawio || sgio) &&
-        (def->device != VIR_DOMAIN_DISK_DEVICE_LUN)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("rawio or sgio can be used only with "
-                         "device='lun'"));
-        goto error;
-    }
-
     if (rawio) {
         if ((def->rawio = virTristateBoolTypeFromString(rawio)) <= 0) {
             virReportError(VIR_ERR_XML_ERROR,