[libvirt] [PATCH] virsh: Report error when taking a snapshot with empty --memspec argument

Peter Krempa pkrempa at redhat.com
Thu Nov 22 10:03:53 UTC 2012


When the value of memspec was empty taking of a snapshot failed without
reporting an error.
---
This is only a quick fix. I think we should improve vshCommandOptStr to detect
this for us and report an appropriate error, but this change will require
a lot of changes not relevant to this problem.
---
 tools/virsh-snapshot.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index 398730c..057ae2d 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -358,7 +358,12 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
     if (desc)
         virBufferEscapeString(&buf, "  <description>%s</description>\n", desc);

-    if (vshCommandOptString(cmd, "memspec", &memspec) < 0 ||
+    if (vshCommandOptString(cmd, "memspec", &memspec) < 0) {
+        vshError(ctl, _("memspec argument must not be empty"));
+        goto cleanup;
+    }
+
+    if (memspec &&
         vshParseSnapshotMemspec(ctl, &buf, memspec) < 0) {
         virBufferFreeAndReset(&buf);
         goto cleanup;
-- 
1.8.0




More information about the libvir-list mailing list