* [PATCH 0/2] libxl: Update of QMP xen-save-devices-state @ 2018-03-13 11:13 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 11:13 ` [PATCH 2/2] libxl_qmp: Tell QEMU about live migration or snapshot Anthony PERARD 0 siblings, 2 replies; 7+ messages in thread From: Anthony PERARD @ 2018-03-13 11:13 UTC (permalink / raw) To: xen-devel; +Cc: Anthony PERARD, Wei Liu, Ian Jackson Handle a new parameter of an existing QMP command. See patch 2 (libxl_qmp: Tell QEMU about live migration or snapshot) for more information. Anthony PERARD (2): libxl: Add a version check of QEMU for QMP commands libxl_qmp: Tell QEMU about live migration or snapshot 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 | 49 +++++++++++++++++++++++++++++++++++++---- 4 files changed, 50 insertions(+), 6 deletions(-) -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] libxl: Add a version check of QEMU for QMP commands 2018-03-13 11:13 [PATCH 0/2] libxl: Update of QMP xen-save-devices-state Anthony PERARD @ 2018-03-13 11:13 ` Anthony PERARD 2018-03-13 17:40 ` Wei Liu 2018-03-13 11:13 ` [PATCH 2/2] libxl_qmp: Tell QEMU about live migration or snapshot Anthony PERARD 1 sibling, 1 reply; 7+ messages in thread From: Anthony PERARD @ 2018-03-13 11:13 UTC (permalink / raw) To: xen-devel; +Cc: Anthony PERARD, Wei Liu, Ian Jackson On connection to QEMU via QMP, the version of QEMU is provided, store it for later use. Add a function qmp_qemu_check_version that can be used to check if QEMU is new enough for certain fonctionnality. This will be used in a moment. As it's a static function, it is commented out until first use, which is in the next patch. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> --- tools/libxl/libxl_qmp.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index eab993aca9..b1c6598cf7 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -75,6 +75,11 @@ struct libxl__qmp_handler { int last_id_used; LIBXL_STAILQ_HEAD(callback_list, callback_id_pair) callback_list; + struct { + int major; + int minor; + int micro; + } version; }; static int qmp_send(libxl__qmp_handler *qmp, @@ -296,9 +301,22 @@ static int qmp_handle_response(libxl__gc *gc, libxl__qmp_handler *qmp, LOGD(DEBUG, qmp->domid, "message type: %s", libxl__qmp_message_type_to_string(type)); switch (type) { - case LIBXL__QMP_MESSAGE_TYPE_QMP: + case LIBXL__QMP_MESSAGE_TYPE_QMP: { + const libxl__json_object *o; + o = libxl__json_map_get("QMP", resp, JSON_MAP); + o = libxl__json_map_get("version", o, JSON_MAP); + o = libxl__json_map_get("qemu", o, JSON_MAP); + qmp->version.major = libxl__json_object_get_integer( + libxl__json_map_get("major", o, JSON_INTEGER)); + qmp->version.minor = libxl__json_object_get_integer( + libxl__json_map_get("minor", o, JSON_INTEGER)); + qmp->version.micro = libxl__json_object_get_integer( + libxl__json_map_get("micro", o, JSON_INTEGER)); + LOGD(DEBUG, qmp->domid, "QEMU version: %d.%d.%d", + qmp->version.major, qmp->version.minor, qmp->version.micro); /* On the greeting message from the server, enable QMP capabilities */ return enable_qmp_capabilities(qmp); + } case LIBXL__QMP_MESSAGE_TYPE_RETURN: { callback_id_pair *pp = qmp_get_callback_from_id(qmp, resp); @@ -332,6 +350,17 @@ 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) +{ + return qmp->version.major > major || + (qmp->version.major == major && + (qmp->version.minor > minor || + (qmp->version.minor == minor && qmp->version.micro >= micro))); +} +#endif + /* * Handler functions */ -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] libxl: Add a version check of QEMU for QMP commands 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 0 siblings, 1 reply; 7+ messages in thread From: Wei Liu @ 2018-03-13 17:40 UTC (permalink / raw) To: Anthony PERARD; +Cc: xen-devel, Ian Jackson, Wei Liu On Tue, Mar 13, 2018 at 11:13:17AM +0000, Anthony PERARD wrote: > On connection to QEMU via QMP, the version of QEMU is provided, store it > for later use. > > Add a function qmp_qemu_check_version that can be used to check if QEMU > is new enough for certain fonctionnality. This will be used in a moment. > > As it's a static function, it is commented out until first use, which is > in the next patch. > > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> > --- > tools/libxl/libxl_qmp.c | 31 ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) > > diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c > index eab993aca9..b1c6598cf7 100644 > --- a/tools/libxl/libxl_qmp.c > +++ b/tools/libxl/libxl_qmp.c > @@ -75,6 +75,11 @@ struct libxl__qmp_handler { > > int last_id_used; > LIBXL_STAILQ_HEAD(callback_list, callback_id_pair) callback_list; > + struct { > + int major; > + int minor; > + int micro; > + } version; > }; > > static int qmp_send(libxl__qmp_handler *qmp, > @@ -296,9 +301,22 @@ static int qmp_handle_response(libxl__gc *gc, libxl__qmp_handler *qmp, > LOGD(DEBUG, qmp->domid, "message type: %s", libxl__qmp_message_type_to_string(type)); > > switch (type) { > - case LIBXL__QMP_MESSAGE_TYPE_QMP: > + case LIBXL__QMP_MESSAGE_TYPE_QMP: { > + const libxl__json_object *o; > + o = libxl__json_map_get("QMP", resp, JSON_MAP); > + o = libxl__json_map_get("version", o, JSON_MAP); > + o = libxl__json_map_get("qemu", o, JSON_MAP); > + qmp->version.major = libxl__json_object_get_integer( > + libxl__json_map_get("major", o, JSON_INTEGER)); > + qmp->version.minor = libxl__json_object_get_integer( > + libxl__json_map_get("minor", o, JSON_INTEGER)); > + qmp->version.micro = libxl__json_object_get_integer( > + libxl__json_map_get("micro", o, JSON_INTEGER)); > + LOGD(DEBUG, qmp->domid, "QEMU version: %d.%d.%d", > + qmp->version.major, qmp->version.minor, qmp->version.micro); > /* On the greeting message from the server, enable QMP capabilities */ > return enable_qmp_capabilities(qmp); > + } Are those fields available in QMP in all the versions we care about? If so, Acked-by: Wei Liu <wei.liu2@citrix.com> _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] libxl: Add a version check of QEMU for QMP commands 2018-03-13 17:40 ` Wei Liu @ 2018-03-13 17:49 ` Anthony PERARD 2018-03-13 17:56 ` Wei Liu 0 siblings, 1 reply; 7+ messages in thread From: Anthony PERARD @ 2018-03-13 17:49 UTC (permalink / raw) To: Wei Liu; +Cc: xen-devel, Ian Jackson On Tue, Mar 13, 2018 at 05:40:08PM +0000, Wei Liu wrote: > On Tue, Mar 13, 2018 at 11:13:17AM +0000, Anthony PERARD wrote: > > On connection to QEMU via QMP, the version of QEMU is provided, store it > > for later use. > > > > Add a function qmp_qemu_check_version that can be used to check if QEMU > > is new enough for certain fonctionnality. This will be used in a moment. > > > > As it's a static function, it is commented out until first use, which is > > in the next patch. > > > > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> > > --- > > tools/libxl/libxl_qmp.c | 31 ++++++++++++++++++++++++++++++- > > 1 file changed, 30 insertions(+), 1 deletion(-) > > > > diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c > > index eab993aca9..b1c6598cf7 100644 > > --- a/tools/libxl/libxl_qmp.c > > +++ b/tools/libxl/libxl_qmp.c > > @@ -75,6 +75,11 @@ struct libxl__qmp_handler { > > > > int last_id_used; > > LIBXL_STAILQ_HEAD(callback_list, callback_id_pair) callback_list; > > + struct { > > + int major; > > + int minor; > > + int micro; > > + } version; > > }; > > > > static int qmp_send(libxl__qmp_handler *qmp, > > @@ -296,9 +301,22 @@ static int qmp_handle_response(libxl__gc *gc, libxl__qmp_handler *qmp, > > LOGD(DEBUG, qmp->domid, "message type: %s", libxl__qmp_message_type_to_string(type)); > > > > switch (type) { > > - case LIBXL__QMP_MESSAGE_TYPE_QMP: > > + case LIBXL__QMP_MESSAGE_TYPE_QMP: { > > + const libxl__json_object *o; > > + o = libxl__json_map_get("QMP", resp, JSON_MAP); > > + o = libxl__json_map_get("version", o, JSON_MAP); > > + o = libxl__json_map_get("qemu", o, JSON_MAP); > > + qmp->version.major = libxl__json_object_get_integer( > > + libxl__json_map_get("major", o, JSON_INTEGER)); > > + qmp->version.minor = libxl__json_object_get_integer( > > + libxl__json_map_get("minor", o, JSON_INTEGER)); > > + qmp->version.micro = libxl__json_object_get_integer( > > + libxl__json_map_get("micro", o, JSON_INTEGER)); > > + LOGD(DEBUG, qmp->domid, "QEMU version: %d.%d.%d", > > + qmp->version.major, qmp->version.minor, qmp->version.micro); > > /* On the greeting message from the server, enable QMP capabilities */ > > return enable_qmp_capabilities(qmp); > > + } > > Are those fields available in QMP in all the versions we care about? I don't care if the field is available or not, the result would be a QEMU version -1.-1.-1 This is why I did not do any check here to find out if a particular value exist. But the version field is part of the QMP protocol, so it should be there. Also yes, the field is available in all QEMU version we care about, e.i. QEMU 2.11 and later. That information is not usefull for older version of QEMU. > If so, > > Acked-by: Wei Liu <wei.liu2@citrix.com> Thanks, -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] libxl: Add a version check of QEMU for QMP commands 2018-03-13 17:49 ` Anthony PERARD @ 2018-03-13 17:56 ` Wei Liu 0 siblings, 0 replies; 7+ messages in thread From: Wei Liu @ 2018-03-13 17:56 UTC (permalink / raw) To: Anthony PERARD; +Cc: xen-devel, Wei Liu, Ian Jackson On Tue, Mar 13, 2018 at 05:49:44PM +0000, Anthony PERARD wrote: > On Tue, Mar 13, 2018 at 05:40:08PM +0000, Wei Liu wrote: > > On Tue, Mar 13, 2018 at 11:13:17AM +0000, Anthony PERARD wrote: > > > On connection to QEMU via QMP, the version of QEMU is provided, store it > > > for later use. > > > > > > Add a function qmp_qemu_check_version that can be used to check if QEMU > > > is new enough for certain fonctionnality. This will be used in a moment. > > > > > > As it's a static function, it is commented out until first use, which is > > > in the next patch. > > > > > > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> > > > --- > > > tools/libxl/libxl_qmp.c | 31 ++++++++++++++++++++++++++++++- > > > 1 file changed, 30 insertions(+), 1 deletion(-) > > > > > > diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c > > > index eab993aca9..b1c6598cf7 100644 > > > --- a/tools/libxl/libxl_qmp.c > > > +++ b/tools/libxl/libxl_qmp.c > > > @@ -75,6 +75,11 @@ struct libxl__qmp_handler { > > > > > > int last_id_used; > > > LIBXL_STAILQ_HEAD(callback_list, callback_id_pair) callback_list; > > > + struct { > > > + int major; > > > + int minor; > > > + int micro; > > > + } version; > > > }; > > > > > > static int qmp_send(libxl__qmp_handler *qmp, > > > @@ -296,9 +301,22 @@ static int qmp_handle_response(libxl__gc *gc, libxl__qmp_handler *qmp, > > > LOGD(DEBUG, qmp->domid, "message type: %s", libxl__qmp_message_type_to_string(type)); > > > > > > switch (type) { > > > - case LIBXL__QMP_MESSAGE_TYPE_QMP: > > > + case LIBXL__QMP_MESSAGE_TYPE_QMP: { > > > + const libxl__json_object *o; > > > + o = libxl__json_map_get("QMP", resp, JSON_MAP); > > > + o = libxl__json_map_get("version", o, JSON_MAP); > > > + o = libxl__json_map_get("qemu", o, JSON_MAP); > > > + qmp->version.major = libxl__json_object_get_integer( > > > + libxl__json_map_get("major", o, JSON_INTEGER)); > > > + qmp->version.minor = libxl__json_object_get_integer( > > > + libxl__json_map_get("minor", o, JSON_INTEGER)); > > > + qmp->version.micro = libxl__json_object_get_integer( > > > + libxl__json_map_get("micro", o, JSON_INTEGER)); > > > + LOGD(DEBUG, qmp->domid, "QEMU version: %d.%d.%d", > > > + qmp->version.major, qmp->version.minor, qmp->version.micro); > > > /* On the greeting message from the server, enable QMP capabilities */ > > > return enable_qmp_capabilities(qmp); > > > + } > > > > Are those fields available in QMP in all the versions we care about? > > I don't care if the field is available or not, the result would be a > QEMU version -1.-1.-1 This is why I did not do any check here to find > out if a particular value exist. But the version field is part of the > QMP protocol, so it should be there. OK that's fine. Wei. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] libxl_qmp: Tell QEMU about live migration or snapshot 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 11:13 ` Anthony PERARD 2018-03-13 17:42 ` Wei Liu 1 sibling, 1 reply; 7+ messages in thread From: Anthony PERARD @ 2018-03-13 11:13 UTC (permalink / raw) To: xen-devel; +Cc: Anthony PERARD, Wei Liu, Ian Jackson 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 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] libxl_qmp: Tell QEMU about live migration or snapshot 2018-03-13 11:13 ` [PATCH 2/2] libxl_qmp: Tell QEMU about live migration or snapshot Anthony PERARD @ 2018-03-13 17:42 ` Wei Liu 0 siblings, 0 replies; 7+ messages in thread From: Wei Liu @ 2018-03-13 17:42 UTC (permalink / raw) To: Anthony PERARD; +Cc: xen-devel, Ian Jackson, Wei Liu On Tue, Mar 13, 2018 at 11:13:18AM +0000, Anthony PERARD wrote: > 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> Acked-by: Wei Liu <wei.liu2@citrix.com> _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-03-13 17:57 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 ` [PATCH 2/2] libxl_qmp: Tell QEMU about live migration or snapshot Anthony PERARD 2018-03-13 17:42 ` Wei Liu
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).