[libvirt] [PATCH 10/14] conf: disk: extract sgio/rawio validation

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


---
 src/conf/domain_conf.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b1432ef..8ac308c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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,
-- 
2.8.1




More information about the libvir-list mailing list