[PATCH] snapshot: conf: Forbid using same file as external snapshot for disks and external snapshot for memory

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

 



When create external system checkpoint snapshot, snapshot file for disks
should not be same with snapshot file for memory

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1148932
Signed-off-by: Shanzhi Yu <shyu@xxxxxxxxxx>
---
 src/conf/snapshot_conf.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 1f83b2c..25af914 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -221,6 +221,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
     char *tmp;
     char *memorySnapshot = NULL;
     char *memoryFile = NULL;
+    char *diskFile = NULL;
     bool offline = !!(flags & VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE);
 
     if (VIR_ALLOC(def) < 0)
@@ -299,6 +300,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
 
     memorySnapshot = virXPathString("string(./memory/@snapshot)", ctxt);
     memoryFile = virXPathString("string(./memory/@file)", ctxt);
+    diskFile = virXPathString("string(./disks/disk/source/@file)", ctxt);
     if (memorySnapshot) {
         def->memory = virDomainSnapshotLocationTypeFromString(memorySnapshot);
         if (def->memory <= 0) {
@@ -322,6 +324,12 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
         }
     } else if (memoryFile) {
         def->memory = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
+        if (diskFile != NULL && STREQ(memoryFile,diskFile)){
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("external snapshot file for disks should not be same"
+                             " with external snapshot file for memory"));
+            goto cleanup;
+        }
     } else if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) {
         def->memory = (offline ?
                        VIR_DOMAIN_SNAPSHOT_LOCATION_NONE :
@@ -336,6 +344,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
     }
     def->file = memoryFile;
     memoryFile = NULL;
+    diskFile = NULL;
 
     /* verify that memory path is absolute */
     if (def->file && def->file[0] != '/') {
@@ -379,6 +388,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
     VIR_FREE(nodes);
     VIR_FREE(memorySnapshot);
     VIR_FREE(memoryFile);
+    VIR_FREE(diskFile);
     if (ret == NULL)
         virDomainSnapshotDefFree(def);
 
-- 
1.9.3

--
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]