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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]