From: Anthony PERARD <anthony.perard@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Anthony PERARD <anthony.perard@citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [PATCH 2/2] libxl_qmp: Tell QEMU about live migration or snapshot
Date: Tue, 13 Mar 2018 11:13:18 +0000 [thread overview]
Message-ID: <20180313111318.24206-3-anthony.perard@citrix.com> (raw)
In-Reply-To: <20180313111318.24206-1-anthony.perard@citrix.com>
Since version 2.10, QEMU will lock the disk images so a second QEMU
instance will not try to open it. This would prevent live migration from
working correctly. A new parameter as been added to the QMP command
"xen-save-devices-state" in QEMU version 2.11 which allow to unlock the
disk image for a live migration, but also keep it locked for a snapshot.
QEMU commit: 5d6c599fe1d69a1bf8c5c4d3c58be2b31cd625ad
"migration, xen: Fix block image lock issue on live migration"
The extra "live" parameter can only be use if QEMU knows about it, so
only add it if qemu is recent enough.
The struct libxl__domain_suspend_state as now knowledge if the suspend
is part of a live migration.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
tools/libxl/libxl_dom_save.c | 1 +
tools/libxl/libxl_dom_suspend.c | 2 +-
tools/libxl/libxl_internal.h | 4 +++-
tools/libxl/libxl_qmp.c | 22 +++++++++++++++++-----
4 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/tools/libxl/libxl_dom_save.c b/tools/libxl/libxl_dom_save.c
index 6487672277..2e9ec4dbf2 100644
--- a/tools/libxl/libxl_dom_save.c
+++ b/tools/libxl/libxl_dom_save.c
@@ -361,6 +361,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)
dsps->ao = ao;
dsps->domid = domid;
+ dsps->live = !!live;
rc = libxl__domain_suspend_init(egc, dsps, type);
if (rc) goto out;
diff --git a/tools/libxl/libxl_dom_suspend.c b/tools/libxl/libxl_dom_suspend.c
index ca41107412..1e904bae8a 100644
--- a/tools/libxl/libxl_dom_suspend.c
+++ b/tools/libxl/libxl_dom_suspend.c
@@ -86,7 +86,7 @@ int libxl__domain_suspend_device_model(libxl__gc *gc,
if (libxl__qmp_stop(gc, domid))
return ERROR_FAIL;
/* Save DM state into filename */
- ret = libxl__qmp_save(gc, domid, filename);
+ ret = libxl__qmp_save(gc, domid, filename, dsps->live);
if (ret)
unlink(filename);
break;
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 506687fbe9..8dd63319fc 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1822,7 +1822,8 @@ _hidden int libxl__qmp_stop(libxl__gc *gc, int domid);
/* Resume QEMU. */
_hidden int libxl__qmp_resume(libxl__gc *gc, int domid);
/* Save current QEMU state into fd. */
-_hidden int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename);
+_hidden int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename,
+ bool live);
/* Load current QEMU state from file. */
_hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filename);
/* Set dirty bitmap logging status */
@@ -3264,6 +3265,7 @@ struct libxl__domain_suspend_state {
/* set by caller of libxl__domain_suspend_init */
libxl__ao *ao;
uint32_t domid;
+ bool live;
/* private */
libxl_domain_type type;
diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index b1c6598cf7..d03cb51668 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -350,7 +350,6 @@ static int qmp_handle_response(libxl__gc *gc, libxl__qmp_handler *qmp,
return 0;
}
-#if 0
static bool qmp_qemu_check_version(libxl__qmp_handler *qmp, int major,
int minor, int micro)
{
@@ -359,7 +358,6 @@ static bool qmp_qemu_check_version(libxl__qmp_handler *qmp, int major,
(qmp->version.minor > minor ||
(qmp->version.minor == minor && qmp->version.micro >= micro)));
}
-#endif
/*
* Handler functions
@@ -942,13 +940,27 @@ int libxl__qmp_system_wakeup(libxl__gc *gc, int domid)
return qmp_run_command(gc, domid, "system_wakeup", NULL, NULL, NULL);
}
-int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename)
+int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename, bool live)
{
libxl__json_object *args = NULL;
+ libxl__qmp_handler *qmp = NULL;
+ int rc;
+
+ qmp = libxl__qmp_initialize(gc, domid);
+ if (!qmp)
+ return ERROR_FAIL;
qmp_parameters_add_string(gc, &args, "filename", (char *)filename);
- return qmp_run_command(gc, domid, "xen-save-devices-state", args,
- NULL, NULL);
+
+ /* live parameter was added to QEMU 2.11. It signal QEMU that the save
+ * operation is for a live migration rather that for taking a snapshot. */
+ if (qmp_qemu_check_version(qmp, 2, 11, 0))
+ qmp_parameters_add_bool(gc, &args, "live", live);
+
+ rc = qmp_synchronous_send(qmp, "xen-save-devices-state", args,
+ NULL, NULL, qmp->timeout);
+ libxl__qmp_close(qmp);
+ return rc;
}
int libxl__qmp_restore(libxl__gc *gc, int domid, const char *state_file)
--
Anthony PERARD
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-03-13 11:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-13 11:13 [PATCH 0/2] libxl: Update of QMP xen-save-devices-state Anthony PERARD
2018-03-13 11:13 ` [PATCH 1/2] libxl: Add a version check of QEMU for QMP commands Anthony PERARD
2018-03-13 17:40 ` Wei Liu
2018-03-13 17:49 ` Anthony PERARD
2018-03-13 17:56 ` Wei Liu
2018-03-13 11:13 ` Anthony PERARD [this message]
2018-03-13 17:42 ` [PATCH 2/2] libxl_qmp: Tell QEMU about live migration or snapshot Wei Liu
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=20180313111318.24206-3-anthony.perard@citrix.com \
--to=anthony.perard@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/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).