Add new qmp commands to suppurt Xen COLO
v2 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
Zhang Chen (3):
Migration: Don't load vmdesc when xen is enabled Add a new qmp command to start/stop replication
Add a new qmp command to do checkpoint, get replication error
docs/qmp-commands.txt | 41 +++++++++++++++++++++++++++++++++++++++++ migration/colo.c | 32 ++++++++++++++++++++++++++++++++ migration/savevm.c | 4 ++++ qapi-schema.json | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+)
Signature · 1 line
2.7.4
PATCH v2 1/3 Migration: Don't load vmdesc when xen is enabled
Xen doesn't need this.
--- migration/savevm.c | 4 ++++ 1 file changed, 4 insertions(+)
migration/savevm.c +4 -0
@@ -1973,6 +1973,10 @@ int qemu_loadvm_state(QEMUFile *f) ret =qemu_file_get_error (f); } +if (xen_enabled ()) { +return ret; + } +/* * Try to read in the VMDESC section as well, so that dumping tools that * intercept our migration stream have the chance to see it.
Signature · 1 line
2.7.4
PATCH v2 2/3 Add a new qmp command to start/stop replication
In reply to Zhang ChenWe can call this qmp command to start/stop replication outside of qemu. Like Xen colo need this function.
--- docs/qmp-commands.txt | 17 +++++++++++++++++ migration/colo.c | 22 ++++++++++++++++++++++ qapi-schema.json | 19 +++++++++++++++++++ 3 files changed, 58 insertions(+)
docs/qmp-commands.txt +17 -0
@@ -432,6 +432,23 @@ Example: "arguments": { "enable": true } } <- { "return": {} } +xen-set-replication +------- + +Enable or disable replication. + +Arguments: + +- "enable": Enable it or disable it. +- "primary": True for primary or false for secondary +- "failover": Enable to do failover when stoping replcation + +Example: + +-> { "execute": "xen-set-replicate", + "arguments": {"enable": true, "primary": false} } +<- { "return": {} } + migrate -------
migration/colo.c +22 -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,26 @@ 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" ); + } + +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 +19 -0
@@ -4676,6 +4676,25 @@ { '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. +# default value is false. +# +# Returns: nothing +# +# 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 for-2.9 V2 2/3] Add a new qmp command to start/stop replication
Quoted 15 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]>--- docs/qmp-commands.txt | 17 +++++++++++++++++ migration/colo.c | 22 ++++++++++++++++++++++ qapi-schema.json | 19 +++++++++++++++++++ 3 files changed, 58 insertions(+)docs/qmp-commands.txt +0
-0
docs/qmp-commands.txt Example: · line 436
Quoted 5 lines
docs/qmp-commands.txt +2
-0@@ -432,6 +432,23 @@ Example: "arguments": { "enable": true } } <- { "return": {} } +xen-set-replication +-------
Much of this file tries to match the ----- divider lines to the length of the line above it (you're short by the length of '-replication')
docs/qmp-commands.txt Example: · line 443
Quoted 7 lines
docs/qmp-commands.txt +7
-0+ +Enable or disable replication. + +Arguments: + +- "enable": Enable it or disable it. +- "primary": True for primary or false for secondary
We aren't very consistent on whether to end in '.'
docs/qmp-commands.txt Example: · line 444
Quoted 1 line
docs/qmp-commands.txt +1
-0+- "failover": Enable to do failover when stoping replcation
"failover": Enable failover when stopping replication (optional, default false)
docs/qmp-commands.txt Example:
Quoted 11 lines
docs/qmp-commands.txt +11
-0+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");
At this point, errp is set, but you fall through...
docs/qmp-commands.txt
Quoted 4 lines
docs/qmp-commands.txt +4
-0+ } + + if (enable) { + replication_start_all(mode, errp);
and could abort if something else also tries to set errp. Simplest is to add a return; statement after error_setg().
Quoted 16 lines
docs/qmp-commands.txt +5
-0+ } else { + replication_stop_all(failover, failover ? NULL : errp); + } +} + static void colo_send_message(QEMUFile *f, COLOMessage msg, Error **errp) {qapi-schema.json +0
-0@@ -4676,6 +4676,25 @@ { 'command': 'xen-load-devices-state', 'data': {'filename': 'str'} } ##
qapi-schema.json line 4688
Quoted 10 lines
qapi-schema.json +10
-0+# @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. +# default value is false.
May want to additionally document that 'failover' cannot be specified if 'enable' is true.
Quoted 13 lines
qapi-schema.json +9
-0+# +# Returns: nothing +# +# 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 · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH for-2.9 V2 2/3] Add a new qmp command to start/stop replication
Quoted 19 lines · Eric Blake
Quoted 18 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]>--- docs/qmp-commands.txt | 17 +++++++++++++++++ migration/colo.c | 22 ++++++++++++++++++++++ qapi-schema.json | 19 +++++++++++++++++++ 3 files changed, 58 insertions(+)docs/qmp-commands.txt +0
-0@@ -432,6 +432,23 @@ Example: "arguments": { "enable": true } } <- { "return": {} }
Quoted 4 lines
docs/qmp-commands.txt Example: · line 436
Quoted 2 lines
docs/qmp-commands.txt +2
-0+xen-set-replication +-------Much of this file tries to match the ----- divider lines to the length of the line above it (you're short by the length of '-replication')
OK~ I will add '----' match the length of '-replication',
and I find some command have same problem like 'xen-set-global-dirty-log', Should I send another patch to fix it?
Quoted 9 lines
docs/qmp-commands.txt Example: · line 443
Quoted 8 lines
docs/qmp-commands.txt +7
-0+ +Enable or disable replication. + +Arguments: + +- "enable": Enable it or disable it. +- "primary": True for primary or false for secondaryWe aren't very consistent on whether to end in '.'
I will fix it.
Quoted 3 lines
docs/qmp-commands.txt Example: · line 444
Quoted 1 line
docs/qmp-commands.txt +1
-0+- "failover": Enable to do failover when stoping replcation"failover": Enable failover when stopping replication (optional, default false)
I got it.
Quoted 13 lines
docs/qmp-commands.txt Example:
Quoted 12 lines
docs/qmp-commands.txt +11
-0+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");At this point, errp is set, but you fall through...
I will add a 'return' here.
Quoted 7 lines
docs/qmp-commands.txt
Quoted 5 lines
docs/qmp-commands.txt +4
-0+ } + + if (enable) { + replication_start_all(mode, errp);and could abort if something else also tries to set errp. Simplest is to add a return; statement after
error_setg().
Yes.
Quoted 15 lines
Quoted 15 lines
docs/qmp-commands.txt +5
-0+ } else { + replication_stop_all(failover, failover ? NULL : errp); + } +} + static void colo_send_message(QEMUFile *f, COLOMessage msg, Error **errp) {qapi-schema.json +0
-0@@ -4676,6 +4676,25 @@ { 'command': 'xen-load-devices-state', 'data': {'filename': 'str'} }
Quoted 13 lines
qapi-schema.json line 4688
Quoted 11 lines
qapi-schema.json +10
-0## +# @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. +# default value is false.May want to additionally document that 'failover' cannot be specified if 'enable' is true.
OK.
Thanks
Zhang Chen
Quoted 13 lines
Quoted 13 lines
qapi-schema.json +9
-0+# +# Returns: nothing +# +# 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 · 2 lines
Thanks zhangchen
PATCH v2 3/3 Add a new qmp command to do checkpoint, get replication error
In reply to Zhang ChenWe can call this qmp command to do checkpoint outside of qemu. Like Xen colo need this function.
--- docs/qmp-commands.txt | 24 ++++++++++++++++++++++++ migration/colo.c | 10 ++++++++++ qapi-schema.json | 22 ++++++++++++++++++++++ 3 files changed, 56 insertions(+)
docs/qmp-commands.txt +24 -0
@@ -449,6 +449,30 @@ Example: "arguments": {"enable": true, "primary": false} } <- { "return": {} } +xen-get-replication-error +------- + +Get replication error that occurs when vm is running + +Arguments: None + +Example: + +-> { "execute": "xen-get-replication-error" } +<- { "return": {} } + +xen-do-checkpoint +------- + +Do checkpoint + +Arguments: None + +Example: + +-> { "execute": "xen-do-checkpoint" } +<- { "return": {} } + migrate -------
migration/colo.c +10 -0
@@ -126,6 +126,16 @@ void qmp_xen_set_replication(bool enable, bool primary, } } +void qmp_xen_get_replication_error (Error **errp) + { +replication_get_error_all (errp); + } + +void qmp_xen_do_checkpoint (Error **errp) + { +replication_do_checkpoint_all (errp); + } +static void colo_send_message (QEMUFile *f,COLOMessage msg,Error **errp) {
qapi-schema.json +22 -0
@@ -4695,6 +4695,28 @@ 'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' } } ## +# @xen-get-replication-error +# +# Get replication error that occurs when the vm is running +# +# Returns: nothing +# +# Since: 2.9 +## +{ 'command': 'xen-get-replication-error' } + +## +# @xen-do-checkpoint +# +# Do checkpoint +# +# Returns: nothing +# +# Since: 2.9 +## +{ 'command': 'xen-do-checkpoint' } + +## # @GICCapability: # # The struct describes capability for a specific GIC (Generic
Signature · 1 line
2.7.4