From: "Denis V. Lunev" <den@openvz.org>
Cc: Juan Quintela <quintela@redhat.com>,
qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
Amit Shah <amit.shah@redhat.com>,
"Denis V. Lunev" <den@openvz.org>
Subject: [Qemu-devel] [PATCH 5/5] qmp: create QMP implementation of loadvm command
Date: Fri, 8 Jan 2016 17:00:10 +0300 [thread overview]
Message-ID: <1452261610-4039-6-git-send-email-den@openvz.org> (raw)
In-Reply-To: <1452261610-4039-1-git-send-email-den@openvz.org>
Unfortunately load_vmstate has a return code (int) and this code is checked
in the other places. Thus we could not just rename it to qmp_loadvm as
returns void.
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>
---
migration/savevm.c | 10 ++++++++++
monitor.c | 8 ++------
qapi-schema.json | 13 +++++++++++++
qmp-commands.hx | 23 +++++++++++++++++++++++
4 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/migration/savevm.c b/migration/savevm.c
index 3de917e..6b34017 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2096,6 +2096,16 @@ int load_vmstate(const char *name, Error **errp)
return 0;
}
+void qmp_loadvm(const char *name, Error **errp)
+{
+ int saved_vm_running = runstate_is_running();
+ vm_stop(RUN_STATE_RESTORE_VM);
+
+ if (load_vmstate(name, errp) == 0 && saved_vm_running) {
+ vm_start();
+ }
+}
+
void qmp_delvm(const char *name, Error **errp)
{
BlockDriverState *bs;
diff --git a/monitor.c b/monitor.c
index 2ddf6c1..c1e998c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1737,16 +1737,12 @@ void qmp_closefd(const char *fdname, Error **errp)
static void hmp_loadvm(Monitor *mon, const QDict *qdict)
{
- int saved_vm_running = runstate_is_running();
const char *name = qdict_get_str(qdict, "name");
Error *local_err = NULL;
- vm_stop(RUN_STATE_RESTORE_VM);
-
- if (load_vmstate(name, &local_err) < 0) {
+ qmp_loadvm(name, &local_err);
+ if (local_err != NULL) {
error_report_err(local_err);
- } else if (saved_vm_running) {
- vm_start();
}
}
diff --git a/qapi-schema.json b/qapi-schema.json
index 94a2764..7d48948 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4080,3 +4080,16 @@
# Since 2.6
##
{ 'command': 'delvm', 'data': {'name': 'str'} }
+
+##
+# @loadvm
+#
+# Load a VM snapshot
+#
+# @name: identifier of a snapshot to be loaded
+#
+# Returns: Nothing on success
+#
+# Since 2.6
+##
+{ 'command': 'loadvm', 'data': {'name': 'str'} }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 5e6f573..9cd1bfe 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -4843,3 +4843,26 @@ EQMP
.args_type = "name:s",
.mhandler.cmd_new = qmp_marshal_delvm,
},
+
+SQMP
+loadvm
+------
+
+Load a VM snapshot
+
+Arguments:
+
+- "name": snapshot name
+
+Example:
+
+-> { "execute": "loadvm", "arguments": { "name": "snapshot1" } }
+<- { "return": {} }
+
+EQMP
+
+ {
+ .name = "loadvm",
+ .args_type = "name:s",
+ .mhandler.cmd_new = qmp_marshal_loadvm,
+ },
--
2.5.0
next prev parent reply other threads:[~2016-01-08 14:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-08 14:00 [Qemu-devel] [PATCH v3 0/5] QMP wrappers for VM snapshot operations Denis V. Lunev
2016-01-08 14:00 ` [Qemu-devel] [PATCH 1/5] qmp: process system-reset event in paused state Denis V. Lunev
2016-01-08 14:00 ` [Qemu-devel] [PATCH 2/5] qmp: create qmp_savevm command Denis V. Lunev
2016-01-08 14:00 ` [Qemu-devel] [PATCH 3/5] qmp: create qmp_delvm command Denis V. Lunev
2016-01-08 14:00 ` [Qemu-devel] [PATCH 4/5] migration: improve error reporting for load_vmstate Denis V. Lunev
2016-01-08 14:00 ` Denis V. Lunev [this message]
2016-01-08 14:06 ` [Qemu-devel] [PATCH v3 0/5] QMP wrappers for VM snapshot operations Denis V. Lunev
-- strict thread matches above, loose matches on Subject: below --
2016-01-08 14:10 [Qemu-devel] [PATCH v4 " Denis V. Lunev
2016-01-08 14:10 ` [Qemu-devel] [PATCH 5/5] qmp: create QMP implementation of loadvm command Denis V. Lunev
2015-12-04 14:44 [Qemu-devel] [PATCH v2 for 2.6 0/5] QMP wrappers for VM snapshot operations Denis V. Lunev
2015-12-04 14:44 ` [Qemu-devel] [PATCH 5/5] qmp: create QMP implementation of loadvm command Denis V. Lunev
2015-12-23 23:15 ` Eric Blake
2015-11-16 15:32 [Qemu-devel] [PATCH 0/5] QMP wrappers for VM snapshot operations Denis V. Lunev
2015-11-16 15:32 ` [Qemu-devel] [PATCH 5/5] qmp: create QMP implementation of loadvm command Denis V. Lunev
2015-11-18 11:41 ` Juan Quintela
2015-12-01 15:19 ` Denis V. Lunev
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=1452261610-4039-6-git-send-email-den@openvz.org \
--to=den@openvz.org \
--cc=amit.shah@redhat.com \
--cc=armbru@redhat.com \
--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).