[PATCH] snapshot: conf: Enforce absolute paths on disk and memory images

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

 



RNG schema as well as the qemu driver requires absolute paths for memory
and disk snapshot image files but the XML parser was not enforcing it.
Add checks to avoid problems in qemu where the configuration it creates
is invalid.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1126329
---
 src/conf/snapshot_conf.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 240ca90..c53a66b 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -177,6 +177,16 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
         }
     }

+    /* validate that the passed path is absolute */
+    if (virStorageSourceIsLocalStorage(def->src) &&
+        def->src->path &&
+        def->src->path[0] != '/') {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("disk snapshot image path '%s' must be absolute"),
+                       def->src->path);
+        goto cleanup;
+    }
+
     if (!def->snapshot && (def->src->path || def->src->format))
         def->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;

@@ -327,6 +337,14 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
     def->file = memoryFile;
     memoryFile = NULL;

+    /* verify that memory path is absolute */
+    if (def->file && def->file[0] != '/') {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("memory snapshot file path (%s) must be absolute"),
+                       def->file);
+        goto cleanup;
+    }
+
     if ((n = virXPathNodeSet("./disks/*", ctxt, &nodes)) < 0)
         goto cleanup;
     if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_DISKS) {
-- 
2.0.2

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