From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Peter Krempa" <pkrempa@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
qemu-block@nongnu.org, "Juan Quintela" <quintela@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Pavel Dovgalyuk" <pavel.dovgaluk@ispras.ru>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Max Reitz" <mreitz@redhat.com>
Subject: [PATCH 2/6] migration: introduce savevm, loadvm, delvm QMP commands
Date: Thu, 2 Jul 2020 18:57:50 +0100 [thread overview]
Message-ID: <20200702175754.2211821-3-berrange@redhat.com> (raw)
In-Reply-To: <20200702175754.2211821-1-berrange@redhat.com>
savevm, loadvm and delvm are some of the few commands that have never
been converted to use QMP. The primary reason for this lack of
conversion is that they block execution of the thread for as long as
they run.
Despite this downside, however, libvirt and applications using libvirt
has used these commands for as long as QMP has existed, via the
"human-monitor-command" passthrough command. IOW, while it is clearly
desirable to be able to fix the blocking problem, this is not an
immediate obstacle to real world usage.
Meanwhile there is a need for other features which involve adding new
parameters to the commands. This is possible with HMP passthrough, but
it provides no reliable way for apps to introspect features, so using
QAPI modelling is highly desirable.
This patch thus introduces trival savevm, loadvm, delvm commands
to QMP that are functionally identical to the HMP counterpart, including
the blocking problem.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
migration/savevm.c | 27 ++++++++++++++++
monitor/hmp-cmds.c | 18 ++---------
qapi/migration.json | 76 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 106 insertions(+), 15 deletions(-)
diff --git a/migration/savevm.c b/migration/savevm.c
index 72dbad95ed..53586a6406 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2943,3 +2943,30 @@ bool vmstate_check_only_migratable(const VMStateDescription *vmsd)
return !(vmsd && vmsd->unmigratable);
}
+
+void qmp_savevm(const char *tag, Error **errp)
+{
+ save_snapshot(tag, errp);
+}
+
+void qmp_loadvm(const char *tag, Error **errp)
+{
+ int saved_vm_running = runstate_is_running();
+
+ vm_stop(RUN_STATE_RESTORE_VM);
+
+ if (load_snapshot(tag, errp) == 0 && saved_vm_running) {
+ vm_start();
+ }
+}
+
+void qmp_delvm(const char *tag, Error **errp)
+{
+ BlockDriverState *bs;
+
+ if (bdrv_all_delete_snapshot(tag, &bs, errp) < 0) {
+ error_prepend(errp,
+ "deleting snapshot on device '%s': ",
+ bdrv_get_device_or_node_name(bs));
+ }
+}
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 2b0b58a336..26a5a1a701 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -1089,15 +1089,9 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)
void hmp_loadvm(Monitor *mon, const QDict *qdict)
{
- int saved_vm_running = runstate_is_running();
- const char *name = qdict_get_str(qdict, "name");
Error *err = NULL;
- vm_stop(RUN_STATE_RESTORE_VM);
-
- if (load_snapshot(name, &err) == 0 && saved_vm_running) {
- vm_start();
- }
+ qmp_loadvm(qdict_get_str(qdict, "name"), &err);
hmp_handle_error(mon, err);
}
@@ -1105,21 +1099,15 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
- save_snapshot(qdict_get_try_str(qdict, "name"), &err);
+ qmp_savevm(qdict_get_try_str(qdict, "name"), &err);
hmp_handle_error(mon, err);
}
void hmp_delvm(Monitor *mon, const QDict *qdict)
{
- BlockDriverState *bs;
Error *err = NULL;
- const char *name = qdict_get_str(qdict, "name");
- if (bdrv_all_delete_snapshot(name, &bs, &err) < 0) {
- error_prepend(&err,
- "deleting snapshot on device '%s': ",
- bdrv_get_device_name(bs));
- }
+ qmp_delvm(qdict_get_str(qdict, "name"), &err);
hmp_handle_error(mon, err);
}
diff --git a/qapi/migration.json b/qapi/migration.json
index d5000558c6..849de38fb0 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -1621,3 +1621,79 @@
##
{ 'event': 'UNPLUG_PRIMARY',
'data': { 'device-id': 'str' } }
+
+##
+# @savevm:
+#
+# Save a VM snapshot
+#
+# @tag: name of the snapshot to create. If it already
+# exists it will be replaced.
+#
+# Note that execution of the VM will be paused during the time
+# it takes to save the snapshot
+#
+# Returns: nothing
+#
+# Example:
+#
+# -> { "execute": "savevm",
+# "data": {
+# "tag": "my-snap"
+# }
+# }
+# <- { "return": { } }
+#
+# Since: 5.2
+##
+{ 'command': 'savevm',
+ 'data': { 'tag': 'str' } }
+
+##
+# @loadvm:
+#
+# Load a VM snapshot
+#
+# @tag: name of the snapshot to load.
+#
+# Returns: nothing
+#
+# Example:
+#
+# -> { "execute": "loadvm",
+# "data": {
+# "tag": "my-snap"
+# }
+# }
+# <- { "return": { } }
+#
+# Since: 5.2
+##
+{ 'command': 'loadvm',
+ 'data': { 'tag': 'str' } }
+
+##
+# @delvm:
+#
+# Delete a VM snapshot
+#
+# @tag: name of the snapshot to delete.
+#
+# Note that execution of the VM will be paused during the time
+# it takes to delete the snapshot
+#
+# Returns: nothing
+#
+# Example:
+#
+# -> { "execute": "delvm",
+# "data": {
+# "tag": "my-snap"
+# }
+# }
+# <- { "return": { } }
+#
+# Since: 5.2
+##
+{ 'command': 'delvm',
+ 'data': { 'tag': 'str' } }
--
2.26.2
next prev parent reply other threads:[~2020-07-02 17:59 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 17:57 [PATCH 0/6] migration: bring savevm/loadvm/delvm over to QMP Daniel P. Berrangé
2020-07-02 17:57 ` [PATCH 1/6] migration: improve error reporting of block driver state name Daniel P. Berrangé
2020-07-02 18:36 ` Eric Blake
2020-07-02 19:13 ` Dr. David Alan Gilbert
2020-07-02 17:57 ` Daniel P. Berrangé [this message]
2020-07-02 18:12 ` [PATCH 2/6] migration: introduce savevm, loadvm, delvm QMP commands Eric Blake
2020-07-02 18:24 ` Daniel P. Berrangé
2020-07-03 15:49 ` Dr. David Alan Gilbert
2020-07-03 16:02 ` Daniel P. Berrangé
2020-07-03 16:10 ` Dr. David Alan Gilbert
2020-07-03 16:16 ` Daniel P. Berrangé
2020-07-03 16:22 ` Dr. David Alan Gilbert
2020-07-03 16:49 ` Daniel P. Berrangé
2020-07-03 17:00 ` Dr. David Alan Gilbert
2020-07-03 17:10 ` Daniel P. Berrangé
2020-07-03 17:26 ` Dr. David Alan Gilbert
2020-07-03 16:24 ` Peter Krempa
2020-07-03 16:26 ` Dr. David Alan Gilbert
2020-07-06 16:15 ` Kevin Wolf
2020-07-07 6:38 ` Peter Krempa
2020-07-07 10:33 ` Kevin Wolf
2020-07-07 10:41 ` Peter Krempa
2020-07-03 17:22 ` Denis V. Lunev
2020-07-02 17:57 ` [PATCH 3/6] block: add ability to filter out blockdevs during snapshot Daniel P. Berrangé
2020-07-02 17:57 ` [PATCH 4/6] block: allow specifying name of block device for vmstate storage Daniel P. Berrangé
2020-07-02 17:57 ` [PATCH 5/6] migration: support excluding block devs in QMP snapshot commands Daniel P. Berrangé
2020-07-06 15:57 ` Kevin Wolf
2020-07-07 9:14 ` Daniel P. Berrangé
2020-07-07 10:11 ` Kevin Wolf
2020-07-02 17:57 ` [PATCH 6/6] migration: support picking vmstate disk " Daniel P. Berrangé
2020-07-02 18:19 ` Eric Blake
2020-07-03 8:37 ` Daniel P. Berrangé
2020-07-02 18:53 ` [PATCH 0/6] migration: bring savevm/loadvm/delvm over to QMP no-reply
2020-07-02 19:07 ` no-reply
2020-07-03 17:15 ` Denis V. Lunev
2020-07-03 17:22 ` Daniel P. Berrangé
2020-07-03 17:29 ` Denis V. Lunev
2020-07-06 14:28 ` Daniel P. Berrangé
2020-07-06 16:07 ` Denis V. Lunev
2020-07-06 15:27 ` Kevin Wolf
2020-07-06 15:29 ` Daniel P. Berrangé
2020-07-06 15:50 ` Kevin Wolf
2020-07-06 16:03 ` Daniel P. Berrangé
2020-07-06 16:10 ` Denis V. Lunev
2020-07-06 16:15 ` Daniel P. Berrangé
2020-07-06 16:21 ` Kevin Wolf
2020-07-07 9:07 ` Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200702175754.2211821-3-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pavel.dovgaluk@ispras.ru \
--cc=pbonzini@redhat.com \
--cc=pkrempa@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).