Add new qmp commands to suppurt Xen COLO
v8 cover Add new qmp commands to suppurt Xen COLO
Xen COLO depend on qemu COLO replication function. So, We need new qmp commands for Xen to use qemu replication.
Corresponding libxl patches already in xen.git.
Commit ID:
ed37ef1f91c20f0ab162ce60f8c38400b917fa64
COLO: introduce new API to prepare/start/do/get_error/stop replication
a0ddc0b359375b2418213966dfbdbfab593ecc6ftools/libxl: introduction of libxl__qmp_restore to load qemu state
note: V8 address Zhanghailiang, Eric Blake and Markus Armbruster's comments.
Zhang Chen (2):
Add a new qmp command to start/stop replication
Add a new qmp command to do checkpoint, query xen replication status
migration/colo.c | 46 +++++++++++++++++++++++++++++++++++ qapi-schema.json | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+)
Signature · 1 line
2.7.4
PATCH v8 1/2 Add a new qmp command to start/stop replication
We can call this qmp command to start/stop replication outside of qemu. Like Xen colo need this function.
--- migration/colo.c | 23 +++++++++++++++++++++++ qapi-schema.json | 25 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+)
migration/colo.c +23 -0
@@ -19,6 +19,8 @@#include "qemu/error-report.h" #include "qapi/error.h" #include "migration/failover.h" +#include "replication.h" +#include "qmp-commands.h" #define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024)
@@ -104,6 +106,27 @@ void colo_do_failover(MigrationState *s) } } +void qmp_xen_set_replication (bool enable,bool primary, +bool has_failover,bool failover, +Error **errp) +{ +ReplicationMode mode = primary ? +REPLICATION_MODE_PRIMARY : +REPLICATION_MODE_SECONDARY ; + +if (has_failover && enable) { +error_setg (errp,"Parameter 'failover' is only for" +" stopping replication" ); +return ; + } + +if (enable) { +replication_start_all (mode, errp); + }else { +replication_stop_all (failover, failover ?NULL : errp); + } +} +static void colo_send_message (QEMUFile *f,COLOMessage msg,Error **errp) {
qapi-schema.json +25 -0
@@ -5906,6 +5906,31 @@ { 'command': 'xen-load-devices-state', 'data': {'filename': 'str'} } ## +# @xen-set-replication: +# +# Enable or disable replication. +# +# @enable: true to enable, false to disable. +# +# @primary: true for primary or false for secondary. +# +# @failover: #optional true to do failover, false to stop. but cannot be +# specified if 'enable' is true. default value is false. +# +# Returns: nothing. +# +# Example: +# +# -> { "execute": "xen-set-replication", +# "arguments": {"enable": true, "primary": false} } +# <- { "return": {} } +# +# Since: 2.9 +## +{ 'command': 'xen-set-replication', + 'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' } } + +## # @GICCapability: # # The struct describes capability for a specific GIC (Generic
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH V8 1/2] Add a new qmp command to start/stop replication
Quoted 23 lines · Zhang Chen
We can call this qmp command to start/stop replication outside of qemu. Like Xen colo need this function.
Signed-off-by Zhang Chen <[email protected]>Signed-off-by Wen Congyang <[email protected]>Reviewed-by Eric Blake <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>Reviewed-by zhanghailiang <[email protected]>---
migration/colo.c +8
-0@@ -104,6 +106,27 @@ void colo_do_failover(MigrationState *s) } } +void qmp_xen_set_replication (bool enable,bool primary, +bool has_failover,bool failover, +Error **errp) +{ +ReplicationMode mode = primary ? +REPLICATION_MODE_PRIMARY : +REPLICATION_MODE_SECONDARY ; +
migration/colo.c void colo_do_failover(MigrationState *s) · line 126
Quoted 10 lines
migration/colo.c +10
-0+if (has_failover && enable) { +error_setg (errp,"Parameter 'failover' is only for" +" stopping replication" ); +return ; + } + +if (enable) { +replication_start_all (mode, errp); + }else { +replication_stop_all (failover, failover ?NULL : errp);
Technically, this is use of failover without first checking has_failover; it would be safer if you inserted:
if (!has_failover) {
failover = NULL;
}earlier in the function to be safe against any callers that don't go through the QAPI-generated code. Fortunately, our QAPI generated code guarantees that failover is NULL when has_failover is false, so my R-b can stand as-is if there is no other reason for a respin.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH V8 1/2] Add a new qmp command to start/stop replication
Quoted 36 lines · Eric Blake
Quoted 22 lines · Zhang Chen
We can call this qmp command to start/stop replication outside of qemu. Like Xen colo need this function.
Signed-off-by Zhang Chen <[email protected]>Signed-off-by Wen Congyang <[email protected]>Reviewed-by Eric Blake <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>Reviewed-by zhanghailiang <[email protected]>---
migration/colo.c +8
-0@@ -104,6 +106,27 @@ void colo_do_failover(MigrationState *s) } } +void qmp_xen_set_replication (bool enable,bool primary, +bool has_failover,bool failover, +Error **errp) +{ +ReplicationMode mode = primary ? +REPLICATION_MODE_PRIMARY : +REPLICATION_MODE_SECONDARY ; +migration/colo.c void colo_do_failover(MigrationState *s) · line 126
Quoted 10 lines
migration/colo.c +10
-0+if (has_failover && enable) { +error_setg (errp,"Parameter 'failover' is only for" +" stopping replication" ); +return ; + } + +if (enable) { +replication_start_all (mode, errp); + }else { +replication_stop_all (failover, failover ?NULL : errp);Technically, this is use of failover without first checking
has_failover; it would be safer if you inserted:
Quoted 3 lines
if (!has_failover) {
failover = NULL;
}OK, I will insert this code in next version.
Thanks
Zhang Chen
Quoted 4 lines
earlier in the function to be safe against any callers that don't go through the QAPI-generated code. Fortunately, our QAPI generated code guarantees that failover is NULL when
has_failoveris false, so my R-b can stand as-is if there is no other reason for a respin.
Signature · 2 lines
Thanks Zhang Chen
PATCH v8 2/2 Add a new qmp command to do checkpoint, query xen replication status
In reply to Zhang ChenWe can call this qmp command to do checkpoint outside of qemu. Xen colo will need this function.
--- migration/colo.c | 23 +++++++++++++++++++++++ qapi-schema.json | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+)
migration/colo.c +23 -0
@@ -127,6 +127,29 @@ void qmp_xen_set_replication(bool enable, bool primary, } } +ReplicationStatus *qmp_query_xen_replication_status (Error **errp) +{ +Error *err =NULL ; +ReplicationStatus *s =g_new0 (ReplicationStatus,1 ); + +replication_get_error_all (&err); +if (err) { + s->status = true; + s->has_desc = true; + s->desc =g_strdup (error_get_pretty (err)); + }else { + s->status = false; + } + +error_free (err); +return s; +} + +void qmp_xen_colo_do_checkpoint (Error **errp) +{ +replication_do_checkpoint_all (errp); +} +static void colo_send_message (QEMUFile *f,COLOMessage msg,Error **errp) {
qapi-schema.json +48 -0
54 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH V8 2/2] Add a new qmp command to do checkpoint, query xen replication status
Quoted 6 lines · Zhang Chen
We can call this qmp command to do checkpoint outside of qemu. Xen colo will need this function.
Signed-off-by Zhang Chen <[email protected]>Signed-off-by Wen Congyang <[email protected]>Reviewed-by Eric Blake <[email protected]>
You made a substantial change to this patch since v7 in response to my comments; when you do that, it's best to remove the R-b to make sure I re-review the changes and am still happy with them.
qapi-schema.json line 5938
Quoted 13 lines
--- migration/colo.c | 23 +++++++++++++++++++++++ qapi-schema.json | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+)##
qapi-schema.json +5
-0+# @ReplicationStatus: +# +# The result format for 'query-xen-replication-status'. +# +# @status: true to error, false to normal.
This is now a poor name for the parameter. Please rename it; probably to @error (if you want to keep true meaning a problem has been detected), or to @okay (if you want to invert the sense, and @desc is only present when @okay is false).
Quoted 5 lines
qapi-schema.json +5
-0+# +# @desc: #optional the human readable error description string, when +# @status is 'true'. +# +# Since: 2.9
qapi-schema.json line 5953
Quoted 10 lines
qapi-schema.json +10
-0+## +{ 'struct': 'ReplicationStatus', + 'data': { 'status': 'bool', '*desc': 'str' } } + +## +# @query-xen-replication-status: +# +# Query replication status while the vm is running. +# +# Returns: A @ReplicationResult objects showing the status.
s/objects/object/
qapi-schema.json line 5958
Quoted 5 lines
qapi-schema.json +5
-0+# +# Example: +# +# -> { "execute": "query-xen-replication-status" } +# <- { "return": { "status": "normal" } }
This example is now wrong.
You'll need a v9.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH V8 2/2] Add a new qmp command to do checkpoint, query xen replication status
Quoted 10 lines · Eric Blake
Quoted 6 lines · Zhang Chen
We can call this qmp command to do checkpoint outside of qemu. Xen colo will need this function.
Signed-off-by Zhang Chen <[email protected]>Signed-off-by Wen Congyang <[email protected]>Reviewed-by Eric Blake <[email protected]>You made a substantial change to this patch since v7 in response to my comments; when you do that, it's best to remove the R-b to make sure I re-review the changes and am still happy with them.
OK, I will remove the R-b in next version.
Quoted 6 lines
Quoted 6 lines
--- migration/colo.c | 23 +++++++++++++++++++++++ qapi-schema.json | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+)
Quoted 10 lines
qapi-schema.json line 5938
Quoted 6 lines
##
qapi-schema.json +5
-0+# @ReplicationStatus: +# +# The result format for 'query-xen-replication-status'. +# +# @status: true to error, false to normal.This is now a poor name for the parameter. Please rename it; probably to @error (if you want to keep true meaning a problem has been detected), or to @okay (if you want to invert the sense, and @desc is only present when @okay is false).
I will rename it to "@error" in next version.
Quoted 17 lines
Quoted 6 lines
qapi-schema.json +5
-0+# +# @desc: #optional the human readable error description string, when +# @status is 'true'. +# +# Since: 2.9qapi-schema.json line 5953
Quoted 10 lines
qapi-schema.json +10
-0+## +{ 'struct': 'ReplicationStatus', + 'data': { 'status': 'bool', '*desc': 'str' } } + +## +# @query-xen-replication-status: +# +# Query replication status while the vm is running. +# +# Returns: A @ReplicationResult objects showing the status.s/objects/object/
I got it.
Quoted 9 lines
qapi-schema.json line 5958
Quoted 6 lines
qapi-schema.json +5
-0+# +# Example: +# +# -> { "execute": "query-xen-replication-status" } +# <- { "return": { "status": "normal" } }This example is now wrong.
You'll need a v9.
Yes, I will send the V9 later.
Thanks
Zhang Chen
Quoted 1 line
Signature · 2 lines
Thanks Zhang Chen
Re: [Qemu-devel] [PATCH V8 2/2] Add a new qmp command to do checkpoint, query xen replication status
In reply to Eric BlakeQuoted 19 lines · Eric Blake
Quoted 6 lines · Zhang Chen
We can call this qmp command to do checkpoint outside of qemu. Xen colo will need this function.
Signed-off-by Zhang Chen <[email protected]>Signed-off-by Wen Congyang <[email protected]>Reviewed-by Eric Blake <[email protected]>You made a substantial change to this patch since v7 in response to my comments; when you do that, it's best to remove the R-b to make sure I re-review the changes and am still happy with them.
Quoted 6 lines
--- migration/colo.c | 23 +++++++++++++++++++++++ qapi-schema.json | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+)
Quoted 11 lines
qapi-schema.json line 5938
Quoted 6 lines
##
qapi-schema.json +5
-0+# @ReplicationStatus: +# +# The result format for 'query-xen-replication-status'. +# +# @status: true to error, false to normal.This is now a poor name for the parameter. Please rename it; probably to @error (if you want to keep true meaning a problem has been detected), or to @okay (if you want to invert the sense, and @desc is only present when @okay is false).
We could replace both members by '*error': 'str', present exactly when status is "bad".
Quoted 27 lines
Quoted 5 lines
qapi-schema.json +5
-0+# +# @desc: #optional the human readable error description string, when +# @status is 'true'. +# +# Since: 2.9qapi-schema.json line 5953
Quoted 10 lines
qapi-schema.json +10
-0+## +{ 'struct': 'ReplicationStatus', + 'data': { 'status': 'bool', '*desc': 'str' } } + +## +# @query-xen-replication-status: +# +# Query replication status while the vm is running. +# +# Returns: A @ReplicationResult objects showing the status.s/objects/object/
qapi-schema.json line 5958
Quoted 5 lines
qapi-schema.json +5
-0+# +# Example: +# +# -> { "execute": "query-xen-replication-status" } +# <- { "return": { "status": "normal" } }This example is now wrong.
You'll need a v9.
Re: [Qemu-devel] [PATCH V8 2/2] Add a new qmp command to do checkpoint, query xen replication status
Quoted 29 lines · Markus Armbruster
Quoted 13 lines · Eric Blake
Quoted 6 lines · Zhang Chen
We can call this qmp command to do checkpoint outside of qemu. Xen colo will need this function.
Signed-off-by Zhang Chen <[email protected]>Signed-off-by Wen Congyang <[email protected]>Reviewed-by Eric Blake <[email protected]>You made a substantial change to this patch since v7 in response to my comments; when you do that, it's best to remove the R-b to make sure I re-review the changes and am still happy with them.
Quoted 10 lines
qapi-schema.json line 5938
Quoted 5 lines
qapi-schema.json +5
-0+# @ReplicationStatus: +# +# The result format for 'query-xen-replication-status'. +# +# @status: true to error, false to normal.This is now a poor name for the parameter. Please rename it; probably to @error (if you want to keep true meaning a problem has been detected), or to @okay (if you want to invert the sense, and @desc is only present when @okay is false).
We could replace both members by '*error': 'str', present exactly when status is "bad".
Quoted 8 lines
Quoted 8 lines
qapi-schema.json line 5946
Quoted 8 lines
qapi-schema.json +8
-0+# +# @desc: #optional the human readable error description string, when +# @status is 'true'. +# +# Since: 2.9 +## +{ 'struct': 'ReplicationStatus', + 'data': { 'status': 'bool', '*desc': 'str' } }
Except that ReplicationStatus would then be the empty struct on success.
I guess that's okay, but seems a bit odd.
Quoted 8 lines
Quoted 8 lines
qapi-schema.json line 5958
Quoted 4 lines
qapi-schema.json +4
-0+# Example: +# +# -> { "execute": "query-xen-replication-status" } +# <- { "return": { "status": "normal" } }This example is now wrong.
You'll need a v9.
which has already been submitted and turned into a pull request:
https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg07652.html
It pre-dated your mandate of "all new QMP commands must have a test":
https://lists.gnu.org/archive/html/qemu-devel/2017-03/msg00296.html
but the idea is still relevant, so a followup patch for 2.9 that adds testsuite coverage of the new commands is appropriate during soft freeze.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org