]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
snapshot: require user to supply external memory file name
authorEric Blake <eblake@redhat.com>
Thu, 15 Nov 2012 23:38:13 +0000 (16:38 -0700)
committerEric Blake <eblake@redhat.com>
Fri, 16 Nov 2012 15:22:13 +0000 (08:22 -0700)
For disk snapshots, the user could request an external snapshot
but not supply a filename; later on, we would check this condition
and generate a suitable name if possible, or gracefully error out
when not possible (such as when the original file was a block
device).  But unless we come up with a suitable way to generate
external memory file names, we have no later code point that was
checking for NULL, so we should forbid this up front.

* src/conf/snapshot_conf.c (virDomainSnapshotDefParseString):
Avoid NULL deref, since we don't generate names yet.

src/conf/snapshot_conf.c

index aa2b5268b47ab8ff3d4f776565f08e5671398648..bff045583199ae8d847431eb1abaedee1c9d8b65 100644 (file)
@@ -293,6 +293,12 @@ virDomainSnapshotDefParseString(const char *xmlStr,
                            memoryFile);
             goto cleanup;
         }
+        if (!memoryFile &&
+            def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("external memory snapshots require a filename"));
+            goto cleanup;
+        }
     } else if (memoryFile) {
         def->memory = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
     } else if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) {