From: Stefano Stabellini <sstabellini@kernel.org>
To: peter.maydell@linaro.org
Cc: sstabellini@kernel.org, qemu-devel@nongnu.org,
anthony.perard@citrix.com, xen-devel@lists.xen.org,
Wen Congyang <wency@cn.fujitsu.com>,
Changlong Xie <xiecl.fnst@cn.fujitsu.com>
Subject: [Qemu-devel] [PULL 2/2] Introduce "xen-load-devices-state"
Date: Mon, 13 Jun 2016 11:57:07 +0100 [thread overview]
Message-ID: <1465815427-22041-2-git-send-email-sstabellini@kernel.org> (raw)
In-Reply-To: <1465815427-22041-1-git-send-email-sstabellini@kernel.org>
From: Wen Congyang <wency@cn.fujitsu.com>
Introduce a "xen-load-devices-state" QAPI command that can be used to
load the state of all devices, but not the RAM or the block devices of
the VM.
We only have hmp commands savevm/loadvm, and qmp commands
xen-save-devices-state.
We use this new command for COLO:
1. suspend both primary vm and secondary vm
2. sync the state
3. resume both primary vm and secondary vm
In such case, we need to update all devices' state in any time.
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
---
migration/savevm.c | 37 +++++++++++++++++++++++++++++++++++++
qapi-schema.json | 14 ++++++++++++++
qmp-commands.hx | 27 +++++++++++++++++++++++++++
3 files changed, 78 insertions(+)
diff --git a/migration/savevm.c b/migration/savevm.c
index 6c21231..ae2ef8b 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -31,6 +31,7 @@
#include "hw/boards.h"
#include "hw/hw.h"
#include "hw/qdev.h"
+#include "hw/xen/xen.h"
#include "net/net.h"
#include "monitor/monitor.h"
#include "sysemu/sysemu.h"
@@ -1754,6 +1755,12 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
return -EINVAL;
}
+ /* Validate if it is a device's state */
+ if (xen_enabled() && se->is_ram) {
+ error_report("loadvm: %s RAM loading not allowed on Xen", idstr);
+ return -EINVAL;
+ }
+
/* Add entry */
le = g_malloc0(sizeof(*le));
@@ -2064,6 +2071,36 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp)
}
}
+void qmp_xen_load_devices_state(const char *filename, Error **errp)
+{
+ QEMUFile *f;
+ QIOChannelFile *ioc;
+ int ret;
+
+ /* Guest must be paused before loading the device state; the RAM state
+ * will already have been loaded by xc
+ */
+ if (runstate_is_running()) {
+ error_setg(errp, "Cannot update device state while vm is running");
+ return;
+ }
+ vm_stop(RUN_STATE_RESTORE_VM);
+
+ ioc = qio_channel_file_new_path(filename, O_RDONLY | O_BINARY, 0, errp);
+ if (!ioc) {
+ return;
+ }
+ f = qemu_fopen_channel_input(QIO_CHANNEL(ioc));
+
+ migration_incoming_state_new(f);
+ ret = qemu_loadvm_state(f);
+ qemu_fclose(f);
+ if (ret < 0) {
+ error_setg(errp, QERR_IO_ERROR);
+ }
+ migration_incoming_state_destroy();
+}
+
int load_vmstate(const char *name)
{
BlockDriverState *bs, *bs_vm_state;
diff --git a/qapi-schema.json b/qapi-schema.json
index 8483bdf..48c3a6f 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4201,6 +4201,20 @@
'data': [ 'none', 'record', 'play' ] }
##
+# @xen-load-devices-state:
+#
+# Load the state of all devices from file. The RAM and the block devices
+# of the VM are not loaded by this command.
+#
+# @filename: the file to load the state of the devices from as binary
+# data. See xen-save-devices-state.txt for a description of the binary
+# format.
+#
+# Since: 2.7
+##
+{ 'command': 'xen-load-devices-state', 'data': {'filename': 'str'} }
+
+##
# @GICCapability:
#
# The struct describes capability for a specific GIC (Generic
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 28801a2..780e7f2 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -587,6 +587,33 @@ Example:
EQMP
{
+ .name = "xen-load-devices-state",
+ .args_type = "filename:F",
+ .mhandler.cmd_new = qmp_marshal_xen_load_devices_state,
+ },
+
+SQMP
+xen-load-devices-state
+----------------------
+
+Load the state of all devices from file. The RAM and the block devices
+of the VM are not loaded by this command.
+
+Arguments:
+
+- "filename": the file to load the state of the devices from as binary
+data. See xen-save-devices-state.txt for a description of the binary
+format.
+
+Example:
+
+-> { "execute": "xen-load-devices-state",
+ "arguments": { "filename": "/tmp/resume" } }
+<- { "return": {} }
+
+EQMP
+
+ {
.name = "xen-set-global-dirty-log",
.args_type = "enable:b",
.mhandler.cmd_new = qmp_marshal_xen_set_global_dirty_log,
--
1.9.1
next prev parent reply other threads:[~2016-06-13 10:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-13 10:54 [Qemu-devel] [PULL 0/2] xen-20160613-tag Stefano Stabellini
2016-06-13 10:57 ` [Qemu-devel] [PULL 1/2] exec: Fix qemu_ram_block_from_host for Xen Stefano Stabellini
2016-06-13 10:57 ` Stefano Stabellini [this message]
2016-06-13 11:48 ` [Qemu-devel] [Xen-devel] [PULL 0/2] xen-20160613-tag Jan Beulich
2016-06-13 13:42 ` Stefano Stabellini
2016-06-13 12:04 ` [Qemu-devel] " Peter Maydell
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=1465815427-22041-2-git-send-email-sstabellini@kernel.org \
--to=sstabellini@kernel.org \
--cc=anthony.perard@citrix.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=wency@cn.fujitsu.com \
--cc=xen-devel@lists.xen.org \
--cc=xiecl.fnst@cn.fujitsu.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).