@@ -342,7 +342,7 @@ ETEXI
.args_type = "name:s",
.params = "tag|id",
.help = "delete a VM snapshot from its tag or id",
- .mhandler.cmd = do_delvm,
+ .mhandler.cmd = hmp_vm_snapshot_delete,
},
STEXI
@@ -1353,3 +1353,13 @@ void hmp_vm_snapshot_load(Monitor *mon, const QDict *qdict)
qmp_vm_snapshot_load(name, &err);
hmp_handle_error(mon, &err);
}
+
+void hmp_vm_snapshot_delete(Monitor *mon, const QDict *qdict)
+{
+ const char *name = qdict_get_str(qdict, "name");
+ Error *err = NULL;
+
+ qmp_vm_snapshot_delete(name, &err);
+
+ hmp_handle_error(mon, &err);
+}
@@ -82,5 +82,6 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
void hmp_vm_snapshot_save(Monitor *mon, const QDict *qdict);
void hmp_vm_snapshot_load(Monitor *mon, const QDict *qdict);
+void hmp_vm_snapshot_delete(Monitor *mon, const QDict *qdict);
#endif
@@ -3051,3 +3051,17 @@
# Since: 1.3
##
{ 'command': 'vm-snapshot-load', 'data': {'name': 'str'} }
+
+##
+# @vm-snapshot-delete:
+#
+# Delete the snapshot identified by tag or id.
+#
+# @name: tag|id of existing snapshot
+#
+# Returns: Nothing on success
+# If an error occurs, GenericError with error message
+#
+# Since: 1.3
+##
+{ 'command': 'vm-snapshot-delete', 'data': {'name': 'str'} }
@@ -1402,6 +1402,30 @@ Example:
EQMP
{
+ .name = "vm-snapshot-delete",
+ .args_type = "name:s",
+ .params = "tag|id",
+ .help = "delete a VM snapshot from its tag or id",
+ .mhandler.cmd_new = qmp_marshal_input_vm_snapshot_delete
+ },
+
+SQMP
+vm-snapshot-delete
+------
+
+Delete the snapshot identified by tag or id.
+
+Arguments:
+
+- "name": tag|id of existing snapshot (json-string)
+
+Example:
+
+-> { "execute": "vm-snapshot-delete", "arguments": { "name": "my_snapshot" } }
+<- { "return": {} }
+
+EQMP
+ {
.name = "qmp_capabilities",
.args_type = "",
.params = "",
@@ -2355,31 +2355,20 @@ void qmp_vm_snapshot_load(const char *name, Error **errp)
}
}
-void do_delvm(Monitor *mon, const QDict *qdict)
+void qmp_vm_snapshot_delete(const char *name, Error **errp)
{
BlockDriverState *bs, *bs1;
- int ret;
- const char *name = qdict_get_str(qdict, "name");
bs = bdrv_snapshots();
if (!bs) {
- monitor_printf(mon, "No block device supports snapshots\n");
+ error_setg(errp, "No block device supports snapshots.");
return;
}
bs1 = NULL;
while ((bs1 = bdrv_next(bs1))) {
if (bdrv_can_snapshot(bs1)) {
- ret = bdrv_snapshot_delete(bs1, name, NULL);
- if (ret < 0) {
- if (ret == -ENOTSUP)
- monitor_printf(mon,
- "Snapshots not supported on device '%s'\n",
- bdrv_get_device_name(bs1));
- else
- monitor_printf(mon, "Error %d while deleting snapshot on "
- "'%s'\n", ret, bdrv_get_device_name(bs1));
- }
+ bdrv_snapshot_delete(bs1, name, errp);
}
}
}
@@ -65,7 +65,6 @@ void qemu_remove_exit_notifier(Notifier *notify);
void qemu_add_machine_init_done_notifier(Notifier *notify);
-void do_delvm(Monitor *mon, const QDict *qdict);
void do_info_snapshots(Monitor *mon);
void qemu_announce_self(void);
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- hmp-commands.hx | 2 +- hmp.c | 10 ++++++++++ hmp.h | 1 + qapi-schema.json | 14 ++++++++++++++ qmp-commands.hx | 24 ++++++++++++++++++++++++ savevm.c | 17 +++-------------- sysemu.h | 1 - 7 files changed, 53 insertions(+), 16 deletions(-)