From: Ján Tomko Date: Mon, 11 Mar 2013 12:22:21 +0000 (+0100) Subject: virsh: fix snapshot-create with no xmlfile X-Git-Tag: v1.0.4-rc1~125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fc5ff11ab796a8ad60e0432373c93d0794fbfc6;p=thirdparty%2Flibvirt.git virsh: fix snapshot-create with no xmlfile Properly check the return value of vshCommandOptStringReq for xmlfile: * error out on incorrect input (--xmlfile '') * use default XML with no --xmlfile specified (Broken by commit b2e8585) Bug: https://bugzilla.redhat.com/show_bug.cgi?id=919826 --- diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index ed410147f6..d994fd91b2 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -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, ""); } else { if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {