Skip to contentSkip to conversation

Add new qmp commands to suppurt Xen COLO

PATCH Superseded Zhang Chen 2 participants 7 messages Feb 24, 2017 – Feb 25, 2017

v9 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Zhang Chen

author
#0 lore raw

v9 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

a0ddc0b359375b2418213966dfbdbfab593ecc6f
tools/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, query xen replication status

 migration/colo.c | 49 +++++++++++++++++++++++++++++++++++++
 qapi-schema.json | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 123 insertions(+)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v9 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 | 26 ++++++++++++++++++++++++++
 qapi-schema.json | 25 +++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
migration/colo.c +26 -0
index 93c85c5..0114899 100644
@@ -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,30 @@ 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 {
+        if (!has_failover) {
+            failover = NULL;
+        }
+        replication_stop_all(failover, failover ? NULL : errp);
+    }
+}
+
 static void colo_send_message(QEMUFile *f, COLOMessage msg,
                               Error **errp)
 {
qapi-schema.json +25 -0
index cbdffdd..9445b93 100644
@@ -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
author
#2 lore raw

PATCH v9 2/2 Add a new qmp command to do checkpoint, query xen replication status

In reply to Zhang Chen

We can call this qmp command to do checkpoint outside of qemu. Xen colo will need this function.

---
 migration/colo.c | 23 +++++++++++++++++++++++
 qapi-schema.json | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)
migration/colo.c +23 -0
index 0114899..2b241b4 100644
@@ -130,6 +130,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->error = true;
+        s->has_desc = true;
+        s->desc = g_strdup(error_get_pretty(err));
+    } else {
+        s->error = 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 +49 -0

55 lines not on this page · raw message

Signature · 1 line
2.7.4
Reviewed-by on v9 2/2
#3 lore raw

Re: [Qemu-devel] [PATCH V9 2/2] Add a new qmp command to do checkpoint, query xen replication status

Quoted 13 lines · Zhang Chen

We can call this qmp command to do checkpoint outside of qemu. Xen colo will need this function.

---
 migration/colo.c | 23 +++++++++++++++++++++++
 qapi-schema.json | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)

+++ b/qapi-schema.json

qapi-schema.json line 5938

Quoted 8 lines
qapi-schema.json +5 -0
@@ -5931,6 +5931,55 @@
   'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' } }
 
 ##
+# @ReplicationStatus:
+#
+# The result format for 'query-xen-replication-status'.
+#
+# @error: true to error, false to normal.

Maybe:

true if an error happened, false if replication is normal

Maintainer could touch that up during application, so it doesn't necessarily require a v10.

qapi-schema.json line 5959

Quoted 12 lines
qapi-schema.json +12 -0
+##
+# @query-xen-replication-status:
+#
+# Query replication status while the vm is running.
+#
+# Returns: A @ReplicationResult object showing the status.
+#
+# Example:
+#
+# -> { "execute": "query-xen-replication-status" }
+# <- { "return": [ { "error": false },
+#                  { "error": true } ] }

This example is bogus. The command does NOT return an array. It is sufficient to use:

{ "return": { "error": false } }

but if you want, you could instead do:

{ "return": { "error": true, "desc": "..." } }

but if you do that, please be sure that desc matches an actual error code that could occur, and not something made up.

If all you do is fix the example with the simpler "error":false (and maybe the maintainer is okay doing that), then you can add:

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#4 lore raw

Re: [Qemu-devel] [PATCH V9 2/2] Add a new qmp command to do checkpoint, query xen replication status

Quoted 23 lines · Eric Blake
Quoted 12 lines · Zhang Chen

We can call this qmp command to do checkpoint outside of qemu. Xen colo will need this function.

---
  migration/colo.c | 23 +++++++++++++++++++++++
  qapi-schema.json | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 72 insertions(+)

+++ b/qapi-schema.json

qapi-schema.json line 5938

Quoted 8 lines
qapi-schema.json +5 -0
@@ -5931,6 +5931,55 @@
    'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' } }
 
  ##
+# @ReplicationStatus:
+#
+# The result format for 'query-xen-replication-status'.
+#
+# @error: true to error, false to normal.

Maybe:

Quoted 4 lines

true if an error happened, false if replication is normal

Maintainer could touch that up during application, so it doesn't necessarily require a v10.

Maintainer may be very busy, I will do this fix in V10.

Quoted 20 lines

qapi-schema.json line 5959

Quoted 13 lines
qapi-schema.json +12 -0
+##
+# @query-xen-replication-status:
+#
+# Query replication status while the vm is running.
+#
+# Returns: A @ReplicationResult object showing the status.
+#
+# Example:
+#
+# -> { "execute": "query-xen-replication-status" }
+# <- { "return": [ { "error": false },
+#                  { "error": true } ] }

This example is bogus. The command does NOT return an array. It is sufficient to use:

{ "return": { "error": false } }

but if you want, you could instead do:

Quoted 8 lines

{ "return": { "error": true, "desc": "..." } }

but if you do that, please be sure that desc matches an actual error code that could occur, and not something made up.

If all you do is fix the example with the simpler "error":false (and maybe the maintainer is okay doing that), then you can add:

I will fix the example in V10, and which maintainer can pick up this patch?

Thanks
Zhang Chen

Signature · 2 lines
Thanks
Zhang Chen
#5 lore raw
In reply to Zhang Chen
Quoted 12 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

a0ddc0b359375b2418213966dfbdbfab593ecc6f
tools/libxl: introduction of libxl__qmp_restore to load qemu state

It's nice to call out what changed between v8 and v9 to focus reviewer's attention on those aspects.

Quoted 9 lines

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 | 49 +++++++++++++++++++++++++++++++++++++
 qapi-schema.json | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 123 insertions(+)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#6 lore raw
Quoted 7 lines · Eric Blake
Quoted 6 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:

Quoted 8 lines
Quoted 6 lines

ed37ef1f91c20f0ab162ce60f8c38400b917fa64
COLO: introduce new API to prepare/start/do/get_error/stop replication

a0ddc0b359375b2418213966dfbdbfab593ecc6f
tools/libxl: introduction of libxl__qmp_restore to load qemu state

It's nice to call out what changed between v8 and v9 to focus reviewer's attention on those aspects.

OK, I will add the note in next version.

Thanks
Zhang Chen

Quoted 9 lines
Quoted 9 lines

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 | 49 +++++++++++++++++++++++++++++++++++++
  qapi-schema.json | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 123 insertions(+)
Signature · 2 lines
Thanks
Zhang Chen