Add new qmp commands to suppurt Xen COLO
v4 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 (2):
Add a new qmp command to start/stop replication
Add a new qmp command to do checkpoint, get replication error
docs/qmp-commands.txt | 42 ++++++++++++++++++++++++++++++++++++++++++ migration/colo.c | 33 +++++++++++++++++++++++++++++++++ qapi-schema.json | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+)
Signature · 1 line
2.7.4
PATCH v4 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.
--- docs/qmp-commands.txt | 18 ++++++++++++++++++ migration/colo.c | 23 +++++++++++++++++++++++ qapi-schema.json | 19 +++++++++++++++++++ 3 files changed, 60 insertions(+)
docs/qmp-commands.txt +18 -0
@@ -432,6 +432,24 @@ 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 failover when stopping replication, but cannot be + specified if 'enable' is true (optional, default false). + +Example: + +-> { "execute": "xen-set-replicate", + "arguments": {"enable": true, "primary": false} } +<- { "return": {} } + migrate -------
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 +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. but cannot be +# specified if 'enable' is true. 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 V4 1/2] Add a new qmp command to start/stop replication
Quoted 10 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]>--- docs/qmp-commands.txt | 18 ++++++++++++++++++ migration/colo.c | 23 +++++++++++++++++++++++ qapi-schema.json | 19 +++++++++++++++++++ 3 files changed, 60 insertions(+)
For the QMP side:
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 V4 1/2] Add a new qmp command to start/stop replication
In reply to Zhang ChenQuoted 24 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]>--- docs/qmp-commands.txt | 18 ++++++++++++++++++ migration/colo.c | 23 +++++++++++++++++++++++ qapi-schema.json | 19 +++++++++++++++++++ 3 files changed, 60 insertions(+)docs/qmp-commands.txt +5
-0@@ -432,6 +432,24 @@ Example: "arguments": { "enable": true } } <- { "return": {} } +xen-set-replication +------------------- + +Enable or disable replication. +
docs/qmp-commands.txt Example: · line 449
Quoted 10 lines
docs/qmp-commands.txt +10
-0+Arguments: + +- "enable": Enable it or disable it. +- "primary": True for primary or false for secondary. +- "failover": Enable failover when stopping replication, but cannot be + specified if 'enable' is true (optional, default false). + +Example: + +-> { "execute": "xen-set-replicate",
Shouldn't this be "xen-set-replication" ?
Quoted 83 lines
docs/qmp-commands.txt +3
-0+ "arguments": {"enable": true, "primary": false} } +<- { "return": {} } + migrate -------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 +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. but cannot be +# specified if 'enable' is true. 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 (GenericSignature · 1 line
2.7.4
PATCH v4 2/2 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
@@ -450,6 +450,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
@@ -127,6 +127,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
Re: [Qemu-devel] [PATCH for-2.9 V4 2/2] Add a new qmp command to do checkpoint, get replication error
Quoted 13 lines · Zhang Chen
We can call this qmp command to do checkpoint outside of qemu. Like Xen colo need this function.
Signed-off-by Zhang Chen <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- docs/qmp-commands.txt | 24 ++++++++++++++++++++++++ migration/colo.c | 10 ++++++++++ qapi-schema.json | 22 ++++++++++++++++++++++ 3 files changed, 56 insertions(+)
migration/colo.c void qmp_xen_set_replication(bool enable, bool primary, · line 133
Quoted 4 lines
migration/colo.c +4
-0+void qmp_xen_get_replication_error (Error **errp) + { +replication_get_error_all (errp); + }
Is this trying to cause a replication error, or is it trying to collect status on whether an error has occurred? The name 'get' usually implies a query that does not change state, but a query usually needs some way to return what was queried back to the user, so a void function with no parameters other than error is odd (either the command succeeds because there was no error, or the command fails with an error message because the query had something to get?).
Quoted 4 lines
+++
b/qapi-schema.jsonqapi-schema.json +0
-0@@ -4695,6 +4695,28 @@ 'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' } }
qapi-schema.json line 4706
Quoted 10 lines
qapi-schema.json +9
-0## +# @xen-get-replication-error +# +# Get replication error that occurs when the vm is running. +# +# Returns: nothing. +# +# Since: 2.9 +## +{ 'command': 'xen-get-replication-error' }
So I don't think this is the right name for its signature, but I don't know what you are trying to accomplish with this command to suggest the right name.
qapi-schema.json line 4717
Quoted 11 lines
qapi-schema.json +11
-0+ +## +# @xen-do-checkpoint +# +# Do checkpoint. +# +# Returns: nothing. +# +# Since: 2.9 +## +{ 'command': 'xen-do-checkpoint' }
This one is probably okay.
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 V4 2/2] Add a new qmp command to do checkpoint, get replication error
Quoted 17 lines · Eric Blake
Quoted 12 lines · Zhang Chen
We can call this qmp command to do checkpoint outside of qemu. Like Xen colo need this function.
Signed-off-by Zhang Chen <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- docs/qmp-commands.txt | 24 ++++++++++++++++++++++++ migration/colo.c | 10 ++++++++++ qapi-schema.json | 22 ++++++++++++++++++++++ 3 files changed, 56 insertions(+)migration/colo.c void qmp_xen_set_replication(bool enable, bool primary, · line 133
Quoted 4 lines
migration/colo.c +4
-0+void qmp_xen_get_replication_error (Error **errp) + { +replication_get_error_all (errp); + }
Quoted 7 lines
Is this trying to cause a replication error, or is it trying to collect status on whether an error has occurred? The name 'get' usually implies a query that does not change state, but a query usually needs some way to return what was queried back to the user, so a void function with no parameters other than error is odd (either the command succeeds because there was no error, or the command fails with an error message because the query had something to get?).
Make sense, this command trying to collect status on whether an error has occurred, and the "replication_get_error_all(errp)" is always succeeds. So, Can you suggest to me the right name?
Quoted 6 lines
Quoted 6 lines
+++
b/qapi-schema.jsonqapi-schema.json +0
-0@@ -4695,6 +4695,28 @@ 'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' } }
Quoted 13 lines
qapi-schema.json line 4706
Quoted 10 lines
qapi-schema.json +9
-0## +# @xen-get-replication-error +# +# Get replication error that occurs when the vm is running. +# +# Returns: nothing. +# +# Since: 2.9 +## +{ 'command': 'xen-get-replication-error' }So I don't think this is the right name for its signature, but I don't know what you are trying to accomplish with this command to suggest the right name.
This interface is called to check if error happened in replication.
Thanks
Zhang Chen
Quoted 14 lines
qapi-schema.json line 4717
Quoted 11 lines
qapi-schema.json +11
-0+ +## +# @xen-do-checkpoint +# +# Do checkpoint. +# +# Returns: nothing. +# +# Since: 2.9 +## +{ 'command': 'xen-do-checkpoint' }This one is probably okay.
Signature · 2 lines
Thanks Zhang Chen
Re: [Qemu-devel] [PATCH for-2.9 V4 2/2] Add a new qmp command to do checkpoint, get replication error
Quoted 12 lines · Zhang Chen
Quoted 11 lines
migration/colo.c void qmp_xen_set_replication(bool enable, bool primary, · line 133
Quoted 4 lines
+void
qmp_xen_get_replication_error(Error **errp)migration/colo.c +3
-0+ { +replication_get_error_all (errp); + }Is this trying to cause a replication error, or is it trying to collect status on whether an error has occurred? The name 'get' usually implies a query that does not change state, but a query usually needs some way to return what was queried back to the user, so a void function with no parameters other than error is odd (either the command succeeds because there was no error, or the command fails with an error message because the query had something to get?).
Quoted 3 lines
Make sense, this command trying to collect status on whether an error has occurred, and the "
replication_get_error_all(errp)" is always succeeds. So, Can you suggest to me the right name?
If replication_get_error_all() always succeeds, then what failure is possible to be checking for?
Maybe the problem is deeper, in that replication_get_error_all() has an unusual signature, and needs to be fixed first. I don't know, and haven't looked; I'm only coming at this from the user interface perspective. But it makes no sense to have a command that queries whether an error occurred, but where an error having occurred is fatal (you want the command to successfully report that an error has occurred, not error out with a second error because a first error was present).
Quoted 8 lines
Quoted 6 lines
qapi-schema.json line 4706
Quoted 3 lines
qapi-schema.json +3
-0+# Since: 2.9 +## +{ 'command': 'xen-get-replication-error' }So I don't think this is the right name for its signature, but I don't know what you are trying to accomplish with this command to suggest the right name.
This interface is called to check if error happened in replication.
Then you probably want a query style interface:
{ 'command': 'query-xen-replication-status',
'returns': 'SomeStruct' }
where SomeStruct contains details such as status (perhaps an enum that reports 'normal' or 'error'), and where you are free to add additional pieces of information that may prove useful later (rather than having to invent yet more commands that give only a boolean result of success or failure based on whether the state is normal or in error).
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 V4 2/2] Add a new qmp command to do checkpoint, get replication error
Quoted 13 lines · Eric Blake
Quoted 11 lines · Zhang Chen
Quoted 11 lines
migration/colo.c void qmp_xen_set_replication(bool enable, bool primary, · line 133
Quoted 4 lines
+void
qmp_xen_get_replication_error(Error **errp)migration/colo.c +3
-0+ { +replication_get_error_all (errp); + }Is this trying to cause a replication error, or is it trying to collect status on whether an error has occurred? The name 'get' usually implies a query that does not change state, but a query usually needs some way to return what was queried back to the user, so a void function with no parameters other than error is odd (either the command succeeds because there was no error, or the command fails with an error message because the query had something to get?).
Quoted 5 lines
Quoted 3 lines
Make sense, this command trying to collect status on whether an error has occurred, and the "
replication_get_error_all(errp)" is always succeeds. So, Can you suggest to me the right name?If
replication_get_error_all()always succeeds, then what failure is possible to be checking for?
We can read the errp to check the last error.
Quoted 8 lines
Maybe the problem is deeper, in that
replication_get_error_all()has an unusual signature, and needs to be fixed first. I don't know, and haven't looked; I'm only coming at this from the user interface perspective. But it makes no sense to have a command that queries whether an error occurred, but where an error having occurred is fatal (you want the command to successfully report that an error has occurred, not error out with a second error because a first error was present).
Do you means we should fix "void replication_get_error_all()" to "int replication_get_error_all()" first for get the return value?
Quoted 10 lines
Quoted 8 lines
Quoted 7 lines
qapi-schema.json line 4706
Quoted 4 lines
qapi-schema.json +3
-0+# Since: 2.9 +## +{ 'command': 'xen-get-replication-error' }So I don't think this is the right name for its signature, but I don't know what you are trying to accomplish with this command to suggest the right name.
This interface is called to check if error happened in replication.
Then you probably want a query style interface:
Quoted 9 lines
{ 'command': 'query-xen-replication-status',
'returns': 'SomeStruct' }where SomeStruct contains details such as status (perhaps an enum that reports 'normal' or 'error'), and where you are free to add additional pieces of information that may prove useful later (rather than having to invent yet more commands that give only a boolean result of success or failure based on whether the state is normal or in error).
Thanks for your suggestion.
Zhang Chen
Signature · 2 lines
Thanks Zhang Chen
Re: [Qemu-devel] [PATCH for-2.9 V4 2/2] Add a new qmp command to do checkpoint, get replication error
Quoted 7 lines · Zhang Chen
Quoted 5 lines
Quoted 3 lines
Make sense, this command trying to collect status on whether an error has occurred, and the "
replication_get_error_all(errp)" is always succeeds. So, Can you suggest to me the right name?If
replication_get_error_all()always succeeds, then what failure is possible to be checking for?We can read the errp to check the last error.
But turning around and reporting an error to the caller is not nice. The caller can't distinguish between "I called the command correctly, and it is telling me the system has encountered a replication error" and "I called the command incorrectly, and it is telling me my usage is wrong even though the system has never encountered a replication error".
Passing information through errp is NOT the right way to successfully
report status.
Quoted 10 lines
Quoted 9 lines
Maybe the problem is deeper, in that
replication_get_error_all()has an unusual signature, and needs to be fixed first. I don't know, and haven't looked; I'm only coming at this from the user interface perspective. But it makes no sense to have a command that queries whether an error occurred, but where an error having occurred is fatal (you want the command to successfully report that an error has occurred, not error out with a second error because a first error was present).
Quoted 2 lines
Do you means we should fix "void
replication_get_error_all()" to "intreplication_get_error_all()" first for get the return value?
Quite possibly yes. But maybe you don't have to do that, and can come up with a scheme where only the QMP command wrapper has to be careful. Perhaps something like this would work:
Quoted 10 lines
Quoted 10 lines
Then you probably want a query style interface:
{ 'command': 'query-xen-replication-status',
'returns': 'SomeStruct' }where SomeStruct contains details such as status (perhaps an enum that reports 'normal' or 'error'), and where you are free to add additional pieces of information that may prove useful later (rather than having to invent yet more commands that give only a boolean result of success or failure based on whether the state is normal or in error).
SomeStruct *qmp_query_xen_replication_status(Error **errp)
{
Error *err = NULL;
SomeStruct *result = g_new0(SomeStruct, 1);
replication_get_error_all(&err);
result.state = err ? SOME_ENUM_ERRORED : SOME_ENUM_NORMAL;
error_free(err);
/* ... and now you can add additional status items to the API,
as needed. errp remains unset, because the command succeeds */
}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 V4 2/2] Add a new qmp command to do checkpoint, get replication error
In reply to Zhang Chen[resend, I don't know how I botched the From: line in my first attempt, or if that botch changed who received the mail]
Quoted 7 lines · Zhang Chen
Quoted 5 lines
Quoted 3 lines
Make sense, this command trying to collect status on whether an error has occurred, and the "
replication_get_error_all(errp)" is always succeeds. So, Can you suggest to me the right name?If
replication_get_error_all()always succeeds, then what failure is possible to be checking for?We can read the errp to check the last error.
But turning around and reporting an error to the caller is not nice. The caller can't distinguish between "I called the command correctly, and it is telling me the system has encountered a replication error" and "I called the command incorrectly, and it is telling me my usage is wrong even though the system has never encountered a replication error".
Passing information through errp is NOT the right way to successfully
report status.
Quoted 10 lines
Quoted 9 lines
Maybe the problem is deeper, in that
replication_get_error_all()has an unusual signature, and needs to be fixed first. I don't know, and haven't looked; I'm only coming at this from the user interface perspective. But it makes no sense to have a command that queries whether an error occurred, but where an error having occurred is fatal (you want the command to successfully report that an error has occurred, not error out with a second error because a first error was present).
Quoted 2 lines
Do you means we should fix "void
replication_get_error_all()" to "intreplication_get_error_all()" first for get the return value?
Quite possibly yes. But maybe you don't have to do that, and can come up with a scheme where only the QMP command wrapper has to be careful. Perhaps something like this would work:
Quoted 10 lines
Quoted 10 lines
Then you probably want a query style interface:
{ 'command': 'query-xen-replication-status',
'returns': 'SomeStruct' }where SomeStruct contains details such as status (perhaps an enum that reports 'normal' or 'error'), and where you are free to add additional pieces of information that may prove useful later (rather than having to invent yet more commands that give only a boolean result of success or failure based on whether the state is normal or in error).
SomeStruct *qmp_query_xen_replication_status(Error **errp)
{
Error *err = NULL;
SomeStruct *result = g_new0(SomeStruct, 1);
replication_get_error_all(&err);
result.state = err ? SOME_ENUM_ERRORED : SOME_ENUM_NORMAL;
error_free(err);
/* ... and now you can add additional status items to the API,
as needed. errp remains unset, because the command succeeds */
}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 V4 2/2] Add a new qmp command to do checkpoint, get replication error
Quoted 42 lines · Eric Blake
[resend, I don't know how I botched the From: line in my first attempt, or if that botch changed who received the mail]
Quoted 6 lines · Zhang Chen
Quoted 5 lines
Quoted 3 lines
Make sense, this command trying to collect status on whether an error has occurred, and the "
replication_get_error_all(errp)" is always succeeds. So, Can you suggest to me the right name?If
replication_get_error_all()always succeeds, then what failure is possible to be checking for?We can read the errp to check the last error.
But turning around and reporting an error to the caller is not nice. The caller can't distinguish between "I called the command correctly, and it is telling me the system has encountered a replication error" and "I called the command incorrectly, and it is telling me my usage is wrong even though the system has never encountered a replication error".
Passing information through errp is NOT the right way to successfully
report status.Quoted 9 lines
Quoted 7 lines
Maybe the problem is deeper, in that
replication_get_error_all()has an unusual signature, and needs to be fixed first. I don't know, and haven't looked; I'm only coming at this from the user interface perspective. But it makes no sense to have a command that queries whether an error occurred, but where an error having occurred is fatal (you want the command to successfully report that an error has occurred, not error out with a second error because a first error was present).Do you means we should fix "void
replication_get_error_all()" to "intreplication_get_error_all()" first for get the return value?Quite possibly yes. But maybe you don't have to do that, and can come up with a scheme where only the QMP command wrapper has to be careful. Perhaps something like this would work:
Quoted 10 lines
Quoted 10 lines
Then you probably want a query style interface:
{ 'command': 'query-xen-replication-status',
'returns': 'SomeStruct' }where SomeStruct contains details such as status (perhaps an enum that reports 'normal' or 'error'), and where you are free to add additional pieces of information that may prove useful later (rather than having to invent yet more commands that give only a boolean result of success or failure based on whether the state is normal or in error).
SomeStruct *qmp_query_xen_replication_status(Error **errp)
Quoted 9 lines
{
Error *err = NULL;
SomeStruct *result = g_new0(SomeStruct, 1);
replication_get_error_all(&err);
result.state = err ? SOME_ENUM_ERRORED : SOME_ENUM_NORMAL;
error_free(err);
/* ... and now you can add additional status items to the API,
as needed. errp remains unset, because the command succeeds */
}Good idea!
I will fix this in next version.
Thanks
Zhang Chen
Quoted 1 line
Signature · 2 lines
Thanks Zhang Chen
Re: [Qemu-devel] [PATCH for-2.9 V4 2/2] Add a new qmp command to do checkpoint, get replication error
In reply to Zhang ChenQuoted 32 lines · Zhang Chen
We can call this qmp command to do checkpoint outside of qemu. Like Xen colo need this function.
Signed-off-by Zhang Chen <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- docs/qmp-commands.txt | 24 ++++++++++++++++++++++++ migration/colo.c | 10 ++++++++++ qapi-schema.json | 22 ++++++++++++++++++++++ 3 files changed, 56 insertions(+)docs/qmp-commands.txt +13
-0@@ -450,6 +450,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
docs/qmp-commands.txt Example: · line 475
Quoted 10 lines
docs/qmp-commands.txt +10
-0+----------------- + +Do checkpoint. + +Arguments: None. + +Example: + +-> { "execute": "xen-do-checkpoint" } +<- { "return": {} }
I don't know much about QMP, but shouldn't these two functions return a success or failure at least? Especially xen-get-replication-error? How does xen-get-replication-error actually return the error?
Please also write this info on the description of the commands (docs/qmp-commands.txt, qapi-schema.json).
Quoted 63 lines
docs/qmp-commands.txt +0
-0migrate -------migration/colo.c +10
-0@@ -127,6 +127,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 (GenericSignature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH for-2.9 V4 2/2] Add a new qmp command to do checkpoint, get replication error
Quoted 47 lines · Stefano Stabellini
Quoted 32 lines · Zhang Chen
We can call this qmp command to do checkpoint outside of qemu. Like Xen colo need this function.
Signed-off-by Zhang Chen <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- docs/qmp-commands.txt | 24 ++++++++++++++++++++++++ migration/colo.c | 10 ++++++++++ qapi-schema.json | 22 ++++++++++++++++++++++ 3 files changed, 56 insertions(+)docs/qmp-commands.txt +13
-0@@ -450,6 +450,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-checkpointdocs/qmp-commands.txt Example: · line 475
Quoted 10 lines
docs/qmp-commands.txt +10
-0+----------------- + +Do checkpoint. + +Arguments: None. + +Example: + +-> { "execute": "xen-do-checkpoint" } +<- { "return": {} }I don't know much about QMP, but shouldn't these two functions return a success or failure at least? Especially xen-get-replication-error? How does xen-get-replication-error actually return the error?
Quoted 3 lines
Please also write this info on the description of the commands (
docs/qmp-commands.txt, qapi-schema.json).
OK, I will add more description of the commands in next version.
Thanks
Zhang Chen
Quoted 66 lines
Quoted 63 lines
docs/qmp-commands.txt +0
-0migrate -------migration/colo.c +10
-0@@ -127,6 +127,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 (GenericSignature · 1 line
2.7.4.
Signature · 2 lines
Thanks Zhang Chen
I am OK with this, if the relevant maintainers (Migration, QMP) ack the patches.
Quoted 28 lines · Zhang Chen
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 oflibxl__qmp_restoreto load qemu stateZhang Chen (2):
Add a new qmp command to start/stop replication
Add a new qmp command to do checkpoint, get replication errordocs/qmp-commands.txt | 42 ++++++++++++++++++++++++++++++++++++++++++ migration/colo.c | 33 +++++++++++++++++++++++++++++++++ qapi-schema.json | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+)Signature · 1 line
2.7.4
Quoted 2 lines · Stefano Stabellini
I am OK with this, if the relevant maintainers (Migration, QMP) ack the patches.
Can you add reviewed-by for this patch set?
Thanks
Zhang Chen
Quoted 32 lines · Zhang Chen
Quoted 13 lines
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 oflibxl__qmp_restoreto load qemu stateQuoted 15 lines
Zhang Chen (2):
Add a new qmp command to start/stop replication
Add a new qmp command to do checkpoint, get replication errordocs/qmp-commands.txt | 42 ++++++++++++++++++++++++++++++++++++++++++ migration/colo.c | 33 +++++++++++++++++++++++++++++++++ qapi-schema.json | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+)Signature · 1 line
2.7.4.
Signature · 2 lines
Thanks Zhang Chen