]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Move checks from virDomainDiskDefPostParse to virDomainDiskDefValidate
authorPeter Krempa <pkrempa@redhat.com>
Wed, 14 Apr 2021 07:36:57 +0000 (09:36 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 19 Apr 2021 12:43:59 +0000 (14:43 +0200)
The moved code contains only checks and does not modify the parsed
document so it doesn't belong into the PostParse code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c
src/conf/domain_validate.c

index 0738bf7f1f81b7cc1d0ecd8ea36daf73d519c9e2..ce0931c1607c52776ac49d31da38795bfac9376a 100644 (file)
@@ -5367,25 +5367,6 @@ virDomainDiskDefPostParse(virDomainDiskDef *disk,
                           const virDomainDef *def,
                           virDomainXMLOption *xmlopt)
 {
-    /* internal snapshots and config files are currently supported
-     * only with rbd: */
-    if (virStorageSourceGetActualType(disk->src) != VIR_STORAGE_TYPE_NETWORK &&
-        disk->src->protocol != VIR_STORAGE_NET_PROTOCOL_RBD) {
-        if (disk->src->snapshot) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("<snapshot> element is currently supported "
-                             "only with 'rbd' disks"));
-            return -1;
-        }
-
-        if (disk->src->configFile) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("<config> element is currently supported "
-                             "only with 'rbd' disks"));
-            return -1;
-        }
-    }
-
     if (disk->src->type == VIR_STORAGE_TYPE_NETWORK &&
         disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI) {
         virDomainPostParseCheckISCSIPath(&disk->src->path);
index b2780b3562e4625311166df7098f768674d322e2..5118d6a25e20f4d36bf79e7c4e31ce572a477e51 100644 (file)
@@ -469,6 +469,24 @@ virDomainDiskDefValidateSourceChainOne(const virStorageSource *src)
         }
     }
 
+    /* internal snapshots and config files are currently supported only with rbd: */
+    if (virStorageSourceGetActualType(src) != VIR_STORAGE_TYPE_NETWORK &&
+        src->protocol != VIR_STORAGE_NET_PROTOCOL_RBD) {
+        if (src->snapshot) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("<snapshot> element is currently supported "
+                             "only with 'rbd' disks"));
+            return -1;
+        }
+
+        if (src->configFile) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("<config> element is currently supported "
+                             "only with 'rbd' disks"));
+            return -1;
+        }
+    }
+
     return 0;
 }