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

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

 



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@xxxxxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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