diff mbox

[v11,19/27] COLO: introduce new API to prepare/start/do/get_error/stop replication

Message ID 1457080891-26054-20-git-send-email-xiecl.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Changlong Xie March 4, 2016, 8:41 a.m. UTC
From: Wen Congyang <wency@cn.fujitsu.com>

We will use qemu block replication, and qemu provides some qmp commands
to prepare replication, start replication, get replication error, and
stop replication. Introduce new API to execute these qmp commands.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/libxl_internal.h | 20 +++++++++
 tools/libxl/libxl_qmp.c      | 96 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 116 insertions(+)

Comments

Ian Jackson March 4, 2016, 5:26 p.m. UTC | #1
Changlong Xie writes ("[PATCH v11 19/27] COLO: introduce new API to prepare/start/do/get_error/stop replication"):
> From: Wen Congyang <wency@cn.fujitsu.com>
> 
> We will use qemu block replication, and qemu provides some qmp commands
> to prepare replication, start replication, get replication error, and
> stop replication. Introduce new API to execute these qmp commands.

How will this work if in future we want to support HVM (or
hvm-lite-ng) guests ?

> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 5160939..8cb9f19 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -1771,6 +1771,26 @@ _hidden int
> libxl__qmp_set_global_dirty_log(libxl__gc ...
> +_hidden int libxl__qmp_nbd_server_add(libxl__gc *gc, int domid, const char *disk);

It's a tiny nit, but can I grumble about the long lines here ?  Less
than ~70-75 characters is best.

Thanks,
Ian.
Ian Jackson March 4, 2016, 5:29 p.m. UTC | #2
Changlong Xie writes ("[PATCH v11 19/27] COLO: introduce new API to prepare/start/do/get_error/stop replication"):
> From: Wen Congyang <wency@cn.fujitsu.com>
> 
> We will use qemu block replication, and qemu provides some qmp commands
> to prepare replication, start replication, get replication error, and
> stop replication. Introduce new API to execute these qmp commands.

Also, my comments about needing to see the status of the corresponding
Qemu upstream patches, apply here too.

Thanks,
Ian.
Wei Liu March 8, 2016, 4:46 p.m. UTC | #3
On Fri, Mar 04, 2016 at 05:26:44PM +0000, Ian Jackson wrote:
> Changlong Xie writes ("[PATCH v11 19/27] COLO: introduce new API to prepare/start/do/get_error/stop replication"):
> > From: Wen Congyang <wency@cn.fujitsu.com>
> > 
> > We will use qemu block replication, and qemu provides some qmp commands
> > to prepare replication, start replication, get replication error, and
> > stop replication. Introduce new API to execute these qmp commands.
> 
> How will this work if in future we want to support HVM (or
> hvm-lite-ng) guests ?
> 

Just to clarify things: all the new functions in this patch are internal
to libxl. So they have no implication on how PVHv2 COLO is implemented
-- it probably won't be using all these functions anyway.

Wei.

> > diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> > index 5160939..8cb9f19 100644
> > --- a/tools/libxl/libxl_internal.h
> > +++ b/tools/libxl/libxl_internal.h
> > @@ -1771,6 +1771,26 @@ _hidden int
> > libxl__qmp_set_global_dirty_log(libxl__gc ...
> > +_hidden int libxl__qmp_nbd_server_add(libxl__gc *gc, int domid, const char *disk);
> 
> It's a tiny nit, but can I grumble about the long lines here ?  Less
> than ~70-75 characters is best.
> 
> Thanks,
> Ian.
Changlong Xie March 18, 2016, 3:44 a.m. UTC | #4
On 03/05/2016 01:26 AM, Ian Jackson wrote:
> Changlong Xie writes ("[PATCH v11 19/27] COLO: introduce new API to prepare/start/do/get_error/stop replication"):
>> From: Wen Congyang <wency@cn.fujitsu.com>
>>
>> We will use qemu block replication, and qemu provides some qmp commands
>> to prepare replication, start replication, get replication error, and
>> stop replication. Introduce new API to execute these qmp commands.
>
> How will this work if in future we want to support HVM (or
> hvm-lite-ng) guests ?

Sorry for bad english, what does "hvm-lite-ng" mean? I can't figure out 
this abbr.

>
>> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
>> index 5160939..8cb9f19 100644
>> --- a/tools/libxl/libxl_internal.h
>> +++ b/tools/libxl/libxl_internal.h
>> @@ -1771,6 +1771,26 @@ _hidden int
>> libxl__qmp_set_global_dirty_log(libxl__gc ...
>> +_hidden int libxl__qmp_nbd_server_add(libxl__gc *gc, int domid, const char *disk);
>
> It's a tiny nit, but can I grumble about the long lines here ?  Less
> than ~70-75 characters is best.
>
> Thanks,
> Ian.
>
>
> .
>
Changlong Xie March 18, 2016, 3:45 a.m. UTC | #5
On 03/05/2016 01:26 AM, Ian Jackson wrote:
> Changlong Xie writes ("[PATCH v11 19/27] COLO: introduce new API to prepare/start/do/get_error/stop replication"):
>> From: Wen Congyang <wency@cn.fujitsu.com>
>>
>> We will use qemu block replication, and qemu provides some qmp commands
>> to prepare replication, start replication, get replication error, and
>> stop replication. Introduce new API to execute these qmp commands.
>
> How will this work if in future we want to support HVM (or
> hvm-lite-ng) guests ?

Sorry for bad english, what does "hvm-lite-ng" mean? I can't figure out 
this abbr.

>
>> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
>> index 5160939..8cb9f19 100644
>> --- a/tools/libxl/libxl_internal.h
>> +++ b/tools/libxl/libxl_internal.h
>> @@ -1771,6 +1771,26 @@ _hidden int
>> libxl__qmp_set_global_dirty_log(libxl__gc ...
>> +_hidden int libxl__qmp_nbd_server_add(libxl__gc *gc, int domid, const char *disk);
>
> It's a tiny nit, but can I grumble about the long lines here ?  Less
> than ~70-75 characters is best.
>

Surely

Thanks
	-Xie

> Thanks,
> Ian.
>
>
> .
>
Changlong Xie March 18, 2016, 3:49 a.m. UTC | #6
On 03/05/2016 01:29 AM, Ian Jackson wrote:
> Changlong Xie writes ("[PATCH v11 19/27] COLO: introduce new API to prepare/start/do/get_error/stop replication"):
>> From: Wen Congyang <wency@cn.fujitsu.com>
>>
>> We will use qemu block replication, and qemu provides some qmp commands
>> to prepare replication, start replication, get replication error, and
>> stop replication. Introduce new API to execute these qmp commands.
>
> Also, my comments about needing to see the status of the corresponding
> Qemu upstream patches, apply here too.

Yes, the lastest version is V16.

http://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg02623.html

Thanks
	-Xie

>
> Thanks,
> Ian.
>
>
> .
>
Wei Liu March 18, 2016, 11:35 a.m. UTC | #7
On Fri, Mar 18, 2016 at 11:44:34AM +0800, Changlong Xie wrote:
> On 03/05/2016 01:26 AM, Ian Jackson wrote:
> >Changlong Xie writes ("[PATCH v11 19/27] COLO: introduce new API to prepare/start/do/get_error/stop replication"):
> >>From: Wen Congyang <wency@cn.fujitsu.com>
> >>
> >>We will use qemu block replication, and qemu provides some qmp commands
> >>to prepare replication, start replication, get replication error, and
> >>stop replication. Introduce new API to execute these qmp commands.
> >
> >How will this work if in future we want to support HVM (or
> >hvm-lite-ng) guests ?
> 
> Sorry for bad english, what does "hvm-lite-ng" mean? I can't figure out this
> abbr.
> 

Oh, sorry for now having explained this earlier.  HVMlite is a new guest
mode. It's basically HVM without QEMU. The official name for that new
mode is not yet coined, so you might see it being referred to as PVHv2,
hvmlite-nodm or some other names, but in essence they point to the same
thing.

For more information:

  http://wiki.xen.org/wiki/Virtualization_Spectrum

And scroll down to the bottom for a nice picture. To avoid further
complicating things, I will dwell into the difference between PVHv1 and
PVHv2 (hvmlite).

Wei.


> >
> >>diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> >>index 5160939..8cb9f19 100644
> >>--- a/tools/libxl/libxl_internal.h
> >>+++ b/tools/libxl/libxl_internal.h
> >>@@ -1771,6 +1771,26 @@ _hidden int
> >>libxl__qmp_set_global_dirty_log(libxl__gc ...
> >>+_hidden int libxl__qmp_nbd_server_add(libxl__gc *gc, int domid, const char *disk);
> >
> >It's a tiny nit, but can I grumble about the long lines here ?  Less
> >than ~70-75 characters is best.
> >
> >Thanks,
> >Ian.
> >
> >
> >.
> >
> 
>
diff mbox

Patch

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 5160939..8cb9f19 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1771,6 +1771,26 @@  _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enabl
 _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk);
 /* Add a virtual CPU */
 _hidden int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int index);
+/* Start NBD server */
+_hidden int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid,
+                                        const char *host, const char *port);
+/* Add a disk to NBD server */
+_hidden int libxl__qmp_nbd_server_add(libxl__gc *gc, int domid, const char *disk);
+/* Start replication */
+_hidden int libxl__qmp_start_replication(libxl__gc *gc, int domid, bool primary);
+/* Get replication error that occurs when the vm is running */
+_hidden int libxl__qmp_get_replication_error(libxl__gc *gc, int domid);
+/* Do checkpoint */
+_hidden int libxl__qmp_do_checkpoint(libxl__gc *gc, int domid);
+/* Stop replication */
+_hidden int libxl__qmp_stop_replication(libxl__gc *gc, int domid, bool primary);
+/* Stop NBD server */
+_hidden int libxl__qmp_nbd_server_stop(libxl__gc *gc, int domid);
+/* Add or remove a child to/from quorum */
+_hidden int libxl__qmp_x_blockdev_change(libxl__gc *gc, int domid, const char *parant,
+                                         const char *child, const char *node);
+/* run a hmp command in qmp mode */
+_hidden int libxl__qmp_hmp(libxl__gc *gc, int domid, const char *command_line);
 /* close and free the QMP handler */
 _hidden void libxl__qmp_close(libxl__qmp_handler *qmp);
 /* remove the socket file, if the file has already been removed,
diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index c0bdfcb..3eb279a 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -979,6 +979,102 @@  int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int idx)
     return qmp_run_command(gc, domid, "cpu-add", args, NULL, NULL);
 }
 
+int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid,
+                                const char *host, const char *port)
+{
+    libxl__json_object *args = NULL;
+    libxl__json_object *addr = NULL;
+    libxl__json_object *data = NULL;
+
+    /* 'addr': {
+     *   'type': 'inet',
+     *   'data': {
+     *     'host': '$nbd_host',
+     *     'port': '$nbd_port'
+     *   }
+     * }
+     */
+    qmp_parameters_add_string(gc, &data, "host", host);
+    qmp_parameters_add_string(gc, &data, "port", port);
+
+    qmp_parameters_add_string(gc, &addr, "type", "inet");
+    qmp_parameters_common_add(gc, &addr, "data", data);
+
+    qmp_parameters_common_add(gc, &args, "addr", addr);
+
+    return qmp_run_command(gc, domid, "nbd-server-start", args, NULL, NULL);
+}
+
+int libxl__qmp_nbd_server_add(libxl__gc *gc, int domid, const char *disk)
+{
+    libxl__json_object *args = NULL;
+
+    qmp_parameters_add_string(gc, &args, "device", disk);
+    qmp_parameters_add_bool(gc, &args, "writable", true);
+
+    return qmp_run_command(gc, domid, "nbd-server-add", args, NULL, NULL);
+}
+
+int libxl__qmp_start_replication(libxl__gc *gc, int domid, bool primary)
+{
+    libxl__json_object *args = NULL;
+
+    qmp_parameters_add_bool(gc, &args, "enable", true);
+    qmp_parameters_add_bool(gc, &args, "primary", primary);
+
+    return qmp_run_command(gc, domid, "xen-set-replication", args, NULL, NULL);
+}
+
+int libxl__qmp_get_replication_error(libxl__gc *gc, int domid)
+{
+    return qmp_run_command(gc, domid, "xen-get-replication-error", NULL,
+                           NULL, NULL);
+}
+
+int libxl__qmp_do_checkpoint(libxl__gc *gc, int domid)
+{
+    return qmp_run_command(gc, domid, "xen-do-checkpoint", NULL, NULL, NULL);
+}
+
+int libxl__qmp_stop_replication(libxl__gc *gc, int domid, bool primary)
+{
+    libxl__json_object *args = NULL;
+
+    qmp_parameters_add_bool(gc, &args, "enable", false);
+    qmp_parameters_add_bool(gc, &args, "primary", primary);
+
+    return qmp_run_command(gc, domid, "xen-set-replication", args, NULL, NULL);
+}
+
+int libxl__qmp_nbd_server_stop(libxl__gc *gc, int domid)
+{
+    return qmp_run_command(gc, domid, "nbd-server-stop", NULL, NULL, NULL);
+}
+
+int libxl__qmp_x_blockdev_change(libxl__gc *gc, int domid, const char *parent,
+                                 const char *child, const char *node)
+{
+    libxl__json_object *args = NULL;
+
+    qmp_parameters_add_string(gc, &args, "parent", parent);
+    if (child)
+        qmp_parameters_add_string(gc, &args, "child", child);
+    if (node)
+        qmp_parameters_add_string(gc, &args, "node", node);
+
+    return qmp_run_command(gc, domid, "x-blockdev-change", args, NULL, NULL);
+}
+
+int libxl__qmp_hmp(libxl__gc *gc, int domid, const char *command_line)
+{
+    libxl__json_object *args = NULL;
+
+    qmp_parameters_add_string(gc, &args, "command-line", command_line);
+
+    return qmp_run_command(gc, domid, "human-monitor-command", args,
+                           NULL, NULL);
+}
+
 int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid,
                                const libxl_domain_config *guest_config)
 {