]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Reject attempts to create snapshots with names containig '/'
authorPeter Krempa <pkrempa@redhat.com>
Thu, 17 Jan 2013 13:07:10 +0000 (14:07 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 21 Jan 2013 10:48:45 +0000 (11:48 +0100)
The snapshot name is used to create path to the definition save file.
When the name contains slashes the creation of the file fails. Reject
such names.

src/qemu/qemu_driver.c

index 2f3fb9e92edf924766d58afacfe9d5237fb4bbe2..3a54228389fdd48eff17aa4969847a31f0254991 100644 (file)
@@ -11347,6 +11347,16 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
                                                 parse_flags)))
         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;
+    }
+
     /* reject the VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag where not supported */
     if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_LIVE &&
         (!virDomainObjIsActive(vm) ||