[libvirt] [PATCH 03/10] conf: snapshot: check disk with path on parse

Nikolay Shirokovskiy nshirokovskiy at virtuozzo.com
Thu Dec 27 10:20:45 UTC 2018


We can move the hunk to the parsing stage. Because if disk->src->path
is set and and disk->snapshot is not then it will be set to external
on parsing stage by the above hunk in virDomainSnapshotDiskDefParseXML.
Disk aligning will not have chance to set disk->snapshot.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy at virtuozzo.com>
---
 src/conf/snapshot_conf.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index db55b4f..bd125dc 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -174,6 +174,15 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
     if (!def->snapshot && (def->src->path || def->src->format))
         def->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
 
+    if (def->src->path &&
+        def->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("file '%s' for disk '%s' requires "
+                         "use of external snapshot mode"),
+                       def->src->path, def->name);
+        goto cleanup;
+    }
+
     ret = 0;
  cleanup:
     ctxt->node = saved;
@@ -591,14 +600,6 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
                            disk->name, tmp);
             goto cleanup;
         }
-        if (disk->src->path &&
-            disk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("file '%s' for disk '%s' requires "
-                             "use of external snapshot mode"),
-                           disk->src->path, disk->name);
-            goto cleanup;
-        }
         if (STRNEQ(disk->name, def->dom->disks[idx]->dst)) {
             VIR_FREE(disk->name);
             if (VIR_STRDUP(disk->name, def->dom->disks[idx]->dst) < 0)
-- 
1.8.3.1




More information about the libvir-list mailing list