[libvirt] [PATCH] qemu: Forbid snapshot names starting with '.'

Peter Krempa pkrempa at redhat.com
Mon Jan 21 21:10:52 UTC 2013


Forbid the names to match the loading procedure of snapshots.
---
 src/qemu/qemu_driver.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3a54228..8286334 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11348,13 +11348,23 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
         goto cleanup;

     /* reject snapshot names containing slashes as snapshot definitions are
-     * saved in files containing the name */
-    if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) &&
-        strchr(def->name, '/')) {
-        virReportError(VIR_ERR_XML_DETAIL,
-                       _("invalid snapshot name '%s': name can't contain '/'"),
-                       def->name);
-        goto cleanup;
+     * saved in files containing the name and names starting with dots */
+    if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
+        if (strchr(def->name, '/')) {
+            virReportError(VIR_ERR_XML_DETAIL,
+                           _("invalid snapshot name '%s': "
+                             "name can't contain '/'"),
+                           def->name);
+            goto cleanup;
+        }
+
+        if (def->name[0] == '.') {
+            virReportError(VIR_ERR_XML_DETAIL,
+                           _("invalid snapshot name '%s': "
+                             "name can't start with '.'"),
+                           def->name);
+            goto cleanup;
+        }
     }

     /* reject the VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag where not supported */
-- 
1.8.1.1




More information about the libvir-list mailing list