mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 19:45:21 +00:00
virsh: Report error when taking a snapshot with empty --memspec argument
When the value of memspec was empty taking of a snapshot failed without reporting an error.
This commit is contained in:
parent
37db3f5dfe
commit
fe910efd8a
@ -358,18 +358,19 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (desc)
|
if (desc)
|
||||||
virBufferEscapeString(&buf, " <description>%s</description>\n", desc);
|
virBufferEscapeString(&buf, " <description>%s</description>\n", desc);
|
||||||
|
|
||||||
if (vshCommandOptString(cmd, "memspec", &memspec) < 0 ||
|
if (vshCommandOptString(cmd, "memspec", &memspec) < 0) {
|
||||||
vshParseSnapshotMemspec(ctl, &buf, memspec) < 0) {
|
vshError(ctl, _("memspec argument must not be empty"));
|
||||||
virBufferFreeAndReset(&buf);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (memspec && vshParseSnapshotMemspec(ctl, &buf, memspec) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (vshCommandOptBool(cmd, "diskspec")) {
|
if (vshCommandOptBool(cmd, "diskspec")) {
|
||||||
virBufferAddLit(&buf, " <disks>\n");
|
virBufferAddLit(&buf, " <disks>\n");
|
||||||
while ((opt = vshCommandOptArgv(cmd, opt))) {
|
while ((opt = vshCommandOptArgv(cmd, opt))) {
|
||||||
if (vshParseSnapshotDiskspec(ctl, &buf, opt->data) < 0) {
|
if (vshParseSnapshotDiskspec(ctl, &buf, opt->data) < 0)
|
||||||
virBufferFreeAndReset(&buf);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
virBufferAddLit(&buf, " </disks>\n");
|
virBufferAddLit(&buf, " </disks>\n");
|
||||||
}
|
}
|
||||||
@ -390,6 +391,7 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
|
|||||||
ret = vshSnapshotCreate(ctl, dom, buffer, flags, NULL);
|
ret = vshSnapshotCreate(ctl, dom, buffer, flags, NULL);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virBufferFreeAndReset(&buf);
|
||||||
VIR_FREE(buffer);
|
VIR_FREE(buffer);
|
||||||
if (dom)
|
if (dom)
|
||||||
virDomainFree(dom);
|
virDomainFree(dom);
|
||||||
|
Loading…
Reference in New Issue
Block a user