@@ -2411,3 +2411,14 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
error_report_err(local_err);
}
}
+
+void hmp_delvm(Monitor *mon, const QDict *qdict)
+{
+ Error *local_err = NULL;
+
+ qmp_delvm(qdict_get_str(qdict, "name"), &local_err);
+
+ if (local_err != NULL) {
+ error_report_err(local_err);
+ }
+}
@@ -2092,17 +2092,15 @@ int load_vmstate(const char *name)
return 0;
}
-void hmp_delvm(Monitor *mon, const QDict *qdict)
+void qmp_delvm(const char *name, Error **errp)
{
BlockDriverState *bs;
- Error *err;
- const char *name = qdict_get_str(qdict, "name");
-
- if (bdrv_all_delete_snapshot(name, &bs, &err) < 0) {
- monitor_printf(mon,
- "Error while deleting snapshot on device '%s': %s\n",
- bdrv_get_device_name(bs), error_get_pretty(err));
- error_free(err);
+ Error *local_err = NULL;
+
+ if (bdrv_all_delete_snapshot(name, &bs, &local_err) < 0) {
+ error_setg(errp, "Error while deleting snapshot on device '%s': %s",
+ bdrv_get_device_name(bs), error_get_pretty(local_err));
+ error_free(local_err);
}
}
@@ -4067,3 +4067,16 @@
# Since 2.6
##
{ 'command': 'savevm', 'data': {'name': 'str'} }
+
+##
+# @delvm
+#
+# Delete a VM snapshot
+#
+# @name: identifier of a snapshot to be deleted
+#
+# Returns: Nothing on success
+#
+# Since 2.6
+##
+{ 'command': 'delvm', 'data': {'name': 'str'} }
@@ -4820,3 +4820,26 @@ EQMP
.args_type = "name:s",
.mhandler.cmd_new = qmp_marshal_savevm,
},
+
+SQMP
+delvm
+-----
+
+Delete a VM snapshot
+
+Arguments:
+
+- "name": snapshot name
+
+Example:
+
+-> { "execute": "delvm", "arguments": { "name": "snapshot1" } }
+<- { "return": {} }
+
+EQMP
+
+ {
+ .name = "delvm",
+ .args_type = "name:s",
+ .mhandler.cmd_new = qmp_marshal_delvm,
+ },
The patch also moves hmp_delvm implementation into hmp.c. This function is just a simple wrapper now and does not have knowledge about migration internals. Signed-off-by: Denis V. Lunev <den@openvz.org> CC: Juan Quintela <quintela@redhat.com> CC: Amit Shah <amit.shah@redhat.com> CC: Markus Armbruster <armbru@redhat.com> CC: Eric Blake <eblake@redhat.com> --- hmp.c | 11 +++++++++++ migration/savevm.c | 16 +++++++--------- qapi-schema.json | 13 +++++++++++++ qmp-commands.hx | 23 +++++++++++++++++++++++ 4 files changed, 54 insertions(+), 9 deletions(-)