]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virsh: fix snapshot-create with no xmlfile
authorJán Tomko <jtomko@redhat.com>
Mon, 11 Mar 2013 12:22:21 +0000 (13:22 +0100)
committerJán Tomko <jtomko@redhat.com>
Mon, 11 Mar 2013 12:39:11 +0000 (13:39 +0100)
Properly check the return value of vshCommandOptStringReq for xmlfile:
* error out on incorrect input (--xmlfile '')
* use default XML <domainsnapshot/> with no --xmlfile specified

(Broken by commit b2e8585)

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=919826

tools/virsh-snapshot.c

index ed410147f6884377631cbbdaec4ad99e6e82f182..d994fd91b2b9444f7d03465d755d62715046917b 100644 (file)
@@ -211,7 +211,9 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
     if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
         goto cleanup;
 
-    if (vshCommandOptStringReq(ctl, cmd, "xmlfile", &from) < 0) {
+    if (vshCommandOptStringReq(ctl, cmd, "xmlfile", &from) < 0)
+        goto cleanup;
+    if (!from) {
         buffer = vshStrdup(ctl, "<domainsnapshot/>");
     } else {
         if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {