[PATCH 5/6] virDomainDiskDefValidate: Move validation of disk target

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The disk target is mandatory and used as a designator in error messages
of other validation steps, so we must validate it first.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_validate.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 9069b60e37..1bc62c364d 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -597,6 +597,20 @@ virDomainDiskDefValidate(const virDomainDef *def,
 {
     virStorageSource *next;

+    /* disk target is used widely in other code so it must be validated first */
+    if (!disk->dst) {
+        if (disk->src->srcpool) {
+            virReportError(VIR_ERR_NO_TARGET, _("pool = '%s', volume = '%s'"),
+                           disk->src->srcpool->pool,
+                           disk->src->srcpool->volume);
+        } else {
+            virReportError(VIR_ERR_NO_TARGET,
+                           disk->src->path ? "%s" : NULL, disk->src->path);
+        }
+
+        return -1;
+    }
+
     if (virDomainDiskDefValidateSource(disk->src) < 0)
         return -1;

@@ -776,19 +790,6 @@ virDomainDiskDefValidate(const virDomainDef *def,
     if (disk->wwn && !virValidateWWN(disk->wwn))
         return -1;

-    if (!disk->dst) {
-        if (disk->src->srcpool) {
-            virReportError(VIR_ERR_NO_TARGET, _("pool = '%s', volume = '%s'"),
-                           disk->src->srcpool->pool,
-                           disk->src->srcpool->volume);
-        } else {
-            virReportError(VIR_ERR_NO_TARGET,
-                           disk->src->path ? "%s" : NULL, disk->src->path);
-        }
-
-        return -1;
-    }
-
     if ((disk->device == VIR_DOMAIN_DISK_DEVICE_DISK ||
          disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) &&
         !STRPREFIX(disk->dst, "hd") &&
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux