]> git.ipfire.org Git - thirdparty/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)
committerDoug Goldstein <cardoe@cardoe.com>
Thu, 14 Mar 2013 04:23:50 +0000 (23:23 -0500)
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
(cherry picked from commit 2fc5ff11ab796a8ad60e0432373c93d0794fbfc6)

tools/virsh-snapshot.c

index 3d82276ec21c8223bf15e048de031346398d4c48..bc11d3f5928ebf9c63ca341851bb29bdda9db75f 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) {