COLO-Proxy: Make Xen COLO use userspace colo-proxy
v3 cover COLO-Proxy: Make Xen COLO use userspace colo-proxy
Because of some reason, We no longer support COLO kernel proxy. So we send this patch set to make Xen use userspace colo-proxy in qemu.
Below is a COLO userspace proxy ascii figure:
Primary qemu Secondary qemu
+--------------------------------------------------------------+ +----------------------------------------------------------------+
| +----------------------------------------------------------+ | | +-----------------------------------------------------------+ |
| | | | | | | |
| | guest | | | | guest | |
| | | | | | | |
| +-------^--------------------------+-----------------------+ | | +---------------------+--------+----------------------------+ |
| | | | | ^ | |
| | | | | | | |
| | +------------------------------------------------------+ | | | |
|netfilter| | | | | | netfilter | | |
| +----------+ +----------------------------+ | | | +-----------------------------------------------------------+ |
| | | | | | out | | | | | | filter excute order | |
| | | | +-----------------------------+ | | | | | | +-------------------> | |
| | | | | | | | | | | | | | TCP | |
| | +-----+--+-+ +-----v----+ +-----v----+ |pri +----+----+sec| | | | +------------+ +---+----+---v+rewriter++ +------------+ | |
| | | | | | | | |in | |in | | | | | | | | | | | | |
| | | filter | | filter | | filter +------> colo <------+ +--------> filter +--> adjust | adjust +--> filter | | |
| | | mirror | |redirector| |redirector| | | compare | | | | | | redirector | | ack | seq | | redirector | | |
| | | | | | | | | | | | | | | | | | | | | | | |
| | +----^-----+ +----+-----+ +----------+ | +---------+ | | | | +------------+ +--------+--------------+ +---+--------+ | |
| | | tx | rx rx | | | | | tx all | rx | |
| | | | | | | | +-----------------------------------------------------------+ |
| | | +--------------+ | | | | | |
| | | filter excute order | | | | | | |
| | | +----------------> | | | +--------------------------------------------------------+ |
| +-----------------------------------------+ | | |
| | | | | |
+--------------------------------------------------------------+ +----------------------------------------------------------------+
|guest receive | guest send
| |
+--------+----------------------------v------------------------+
| | NOTE: filter direction is rx/tx/all
| tap | rx:receive packets sent to the netdev
| | tx:receive packets sent by the netdev
+--------------------------------------------------------------+You can know the detail from here:
http://wiki.qemu.org/Features/COLO
https://github.com/qemu/qemu/blob/master/docs/colo-proxy.txt
V3:
- remove the 'RFC' tag.
- fix some bug in patch 7/7.
- fix codestyle.
V2:
- Address wei's comments, use macro to reuse codes.
- Do some work on the last patch.
- Fix some typo.
- Add LIBXL_HAVE_COLO_USERSPACE_PROXY macro in libxl.h.
- Some bug fix.
V1:
- Initial patch
Zhang Chen (7):
COLO-Proxy: Add remus command to open userspace proxy
COLO-Proxy: Setup userspace colo-proxy on primary side tools/libxl: refactor do_domain_create()
COLO-Proxy: Setup userspace colo-proxy on secondary side
COLO-Proxy: Add primary userspace colo proxy start args
COLO-Proxy: Add secondary userspace colo-proxy start args
COLO-Proxy: Use socket to get checkpoint event.
docs/man/xl.pod.1.in | 5 ++ tools/libxl/libxl.h | 6 ++ tools/libxl/libxl_colo.h | 7 +++ tools/libxl/libxl_colo_proxy.c | 100 +++++++++++++++++++++++++++++ tools/libxl/libxl_colo_restore.c | 19 ++++-- tools/libxl/libxl_colo_save.c | 19 +++++- tools/libxl/libxl_create.c | 21 ++++--- tools/libxl/libxl_dm.c | 132 +++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_nic.c | 109 ++++++++++++++++++++++++++++++++ tools/libxl/libxl_types.idl | 64 ++++++++++++++++--- tools/libxl/xl_cmdimpl.c | 120 +++++++++++++++++++++++++++++++++-- tools/libxl/xl_cmdtable.c | 3 +- 12 files changed, 576 insertions(+), 29 deletions(-)
Signature · 9 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 1/7 COLO-Proxy: Add remus command to open userspace proxy
Add remus '-p' to enable userspace colo proxy(in qemu).
--- docs/man/xl.pod.1.in | 5 +++++ tools/libxl/libxl.h | 6 ++++++ tools/libxl/libxl_colo.h | 5 +++++ tools/libxl/libxl_colo_save.c | 2 ++ tools/libxl/libxl_types.idl | 17 +++++++++-------- tools/libxl/xl_cmdimpl.c | 13 ++++++++++++- tools/libxl/xl_cmdtable.c | 3 ++- 7 files changed, 41 insertions(+), 10 deletions(-)
docs/man/xl.pod.1.in +5 -0
@@ -553,6 +553,11 @@ Disable disk replication. Requires enabling unsafe mode. Enable COLO HA. This conflicts with B<-i> and B<-b>, and memory checkpoint compression must be disabled. +=item B<-p> + +Use userspace COLO Proxy. This option must be used in conjunction +with B<-c>. + =back =item B<pause> I<domain-id>
tools/libxl/libxl.h +6 -0
@@ -870,6 +870,12 @@ typedef struct libxl__ctx libxl_ctx;*/ #define LIBXL_HAVE_REMUS 1 +/* +* LIBXL_HAVE_COLO_USERSPACE_PROXY +* If this is defined, then libxl supports COLO userspace proxy. +*/ +#define LIBXL_HAVE_COLO_USERSPACE_PROXY 1 +typedef uint8_t libxl_mac [6 ];#define LIBXL_MAC_FMT "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"#define LIBXL_MAC_FMTLEN ((2*6)+5)/* 6 hex bytes plus 5 colons */
tools/libxl/libxl_colo.h +5 -0
@@ -64,6 +64,11 @@ struct libxl__colo_proxy_state {int sock_fd;int index; +/* +* Private, True means use userspace colo proxy +* False means use kernel colo proxy. +*/ +bool is_userspace_proxy; };struct libxl__colo_save_state {
tools/libxl/libxl_colo_save.c +2 -0
@@ -101,6 +101,8 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) css->qdisk_setuped = false; css->qdisk_used = false;libxl__ev_child_init (&css->child); + css->cps.is_userspace_proxy = +libxl_defbool_val (dss->remus->userspace_colo_proxy);if (dss->remus->netbufscript) css->colo_proxy_script =libxl__strdup (gc, dss->remus->netbufscript);
tools/libxl/libxl_types.idl +9 -8
@@ -844,14 +844,15 @@ libxl_sched_credit2_params = Struct("sched_credit2_params", [ ], dispose_fn=None) libxl_domain_remus_info = Struct("domain_remus_info",[ - ("interval", integer), - ("allow_unsafe", libxl_defbool), - ("blackhole", libxl_defbool), - ("compression", libxl_defbool), - ("netbuf", libxl_defbool), - ("netbufscript", string), - ("diskbuf", libxl_defbool), - ("colo", libxl_defbool) + ("interval", integer), + ("allow_unsafe", libxl_defbool), + ("blackhole", libxl_defbool), + ("compression", libxl_defbool), + ("netbuf", libxl_defbool), + ("netbufscript", string), + ("diskbuf", libxl_defbool), + ("colo", libxl_defbool), + ("userspace_colo_proxy", libxl_defbool) ]) libxl_event_type = Enumeration("event_type", [
tools/libxl/xl_cmdimpl.c +12 -1
@@ -8893,7 +8893,7 @@ int main_remus(int argc, char **argv)memset (&r_info,0 ,sizeof (libxl_domain_remus_info)); - SWITCH_FOREACH_OPT(opt, "Fbundi:s:N:ec", NULL, "remus", 2) { + SWITCH_FOREACH_OPT(opt, "Fbundi:s:N:ecp", NULL, "remus", 2) {case 'i' : r_info.interval =atoi (optarg);break ;
@@ -8923,6 +8923,9 @@ int main_remus(int argc, char **argv)break ;case 'c' :libxl_defbool_set (&r_info.colo, true); +break ; +case 'p' : +libxl_defbool_set (&r_info.userspace_colo_proxy, true); } domid =find_domain (argv[optind]);
@@ -8931,9 +8934,17 @@ int main_remus(int argc, char **argv)/* Defaults */ libxl_defbool_setdefault (&r_info.blackhole, false);libxl_defbool_setdefault (&r_info.colo, false); +libxl_defbool_setdefault (&r_info.userspace_colo_proxy, false); +if (!libxl_defbool_val (r_info.colo) && !r_info.interval) r_info.interval =200 ; +if (libxl_defbool_val (r_info.userspace_colo_proxy) && + !libxl_defbool_val (r_info.colo)) { +fprintf (stderr,"Option -p must be used in conjunction with -c" ); +exit (-1 ); + } +if (libxl_defbool_val (r_info.colo)) { if (r_info.interval || libxl_defbool_val(r_info.blackhole) || !libxl_defbool_is_default(r_info.netbuf) ||
tools/libxl/xl_cmdtable.c +2 -1
@@ -506,7 +506,8 @@ struct cmd_spec cmd_table[] = { "-n Disable network output buffering. Works only in unsafe mode.\n" "-d Disable disk replication. Works only in unsafe mode.\n" "-c Enable COLO HA. It is conflict with -i and -b, and memory\n" - " checkpoint must be disabled" + " checkpoint must be disabled.\n" + "-p Use COLO userspace proxy." }, #endif { "devd",
Signature · 9 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH V3 1/7] COLO-Proxy: Add remus command to open userspace proxy
Quoted 34 lines · Zhang Chen
Add remus '-p' to enable userspace colo proxy(in qemu).
Signed-off-by Zhang Chen <[email protected]>--- docs/man/xl.pod.1.in | 5 +++++ tools/libxl/libxl.h | 6 ++++++ tools/libxl/libxl_colo.h | 5 +++++ tools/libxl/libxl_colo_save.c | 2 ++ tools/libxl/libxl_types.idl | 17 +++++++++-------- tools/libxl/xl_cmdimpl.c | 13 ++++++++++++- tools/libxl/xl_cmdtable.c | 3 ++- 7 files changed, 41 insertions(+), 10 deletions(-)docs/man/xl.pod.1.in +5
-0@@ -553,6 +553,11 @@ Disable disk replication. Requires enabling unsafe mode. Enable COLO HA. This conflicts with B<-i> and B<-b>, and memory checkpoint compression must be disabled. +=item B<-p> + +Use userspace COLO Proxy. This option must be used in conjunction +with B<-c>. + =back =item B<pause> I<domain-id>tools/libxl/libxl.h +0
-0
tools/libxl/libxl.h typedef struct libxl__ctx libxl_ctx; · line 878
Quoted 9 lines
tools/libxl/libxl.h +6
-0@@ -870,6 +870,12 @@ typedef struct libxl__ctx libxl_ctx;*/ #define LIBXL_HAVE_REMUS 1 +/* +* LIBXL_HAVE_COLO_USERSPACE_PROXY +* If this is defined, then libxl supports COLO userspace proxy. +*/ +#define LIBXL_HAVE_COLO_USERSPACE_PROXY 1 +
Please add this macro in a separate patch. It shall be the last patch of this series. That way we don't break bisection for libxl users.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH V3 1/7] COLO-Proxy: Add remus command to open userspace proxy
Quoted 38 lines · Wei Liu
Quoted 37 lines · Zhang Chen
Add remus '-p' to enable userspace colo proxy(in qemu).
Signed-off-by Zhang Chen <[email protected]>--- docs/man/xl.pod.1.in | 5 +++++ tools/libxl/libxl.h | 6 ++++++ tools/libxl/libxl_colo.h | 5 +++++ tools/libxl/libxl_colo_save.c | 2 ++ tools/libxl/libxl_types.idl | 17 +++++++++-------- tools/libxl/xl_cmdimpl.c | 13 ++++++++++++- tools/libxl/xl_cmdtable.c | 3 ++- 7 files changed, 41 insertions(+), 10 deletions(-)docs/man/xl.pod.1.in +5
-0@@ -553,6 +553,11 @@ Disable disk replication. Requires enabling unsafe mode. Enable COLO HA. This conflicts with B<-i> and B<-b>, and memory checkpoint compression must be disabled. +=item B<-p> + +Use userspace COLO Proxy. This option must be used in conjunction +with B<-c>. + =back =item B<pause> I<domain-id>tools/libxl/libxl.h +0
-0@@ -870,6 +870,12 @@ typedef struct libxl__ctx libxl_ctx;*/ #define LIBXL_HAVE_REMUS 1
Quoted 8 lines
tools/libxl/libxl.h typedef struct libxl__ctx libxl_ctx; · line 878
Quoted 6 lines
tools/libxl/libxl.h +6
-0+/* +* LIBXL_HAVE_COLO_USERSPACE_PROXY +* If this is defined, then libxl supports COLO userspace proxy. +*/ +#define LIBXL_HAVE_COLO_USERSPACE_PROXY 1 +Please add this macro in a separate patch. It shall be the last patch of this series. That way we don't break bisection for libxl users.
I got your point.
Thanks
Zhang Chen
Quoted 6 lines
Wei.
.
Signature · 10 lines
Thanks Zhang Chen _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 2/7 COLO-Proxy: Setup userspace colo-proxy on primary side
In reply to Zhang ChenIn this patch we close kernel COLO-Proxy on primary side.
--- tools/libxl/libxl_colo_proxy.c | 27 +++++++++++++++++++++++++++ tools/libxl/libxl_colo_save.c | 9 +++++++-- 2 files changed, 34 insertions(+), 2 deletions(-)
tools/libxl/libxl_colo_proxy.c +27 -0
@@ -152,6 +152,10 @@ int colo_proxy_setup(libxl__colo_proxy_state *cps)STATE_AO_GC (cps->ao); +/* If enable userspace proxy mode, we don't need setup kernel proxy */ +if (cps->is_userspace_proxy) +return 0 ; + skfd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_COLO );if (skfd <0 ) {LOGD (ERROR , ao->domid,"can not create a netlink socket: %s" ,strerror (errno));
@@ -222,6 +226,13 @@ out:void colo_proxy_teardown (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need teardown kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +if (cps->sock_fd >=0 ) {close (cps->sock_fd); cps->sock_fd =-1 ;
@@ -232,6 +243,13 @@ void colo_proxy_teardown(libxl__colo_proxy_state *cps)void colo_proxy_preresume (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need preresume kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +colo_proxy_send (cps,NULL ,0 ,COLO_CHECKPOINT );/* TODO: need to handle if the call fails... */ }
@@ -262,6 +280,15 @@ int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,STATE_AO_GC (cps->ao); +/* +* enable userspace proxy mode, tmp sleep. +* then we will add qemu API support this func. +*/ +if (cps->is_userspace_proxy) { +sleep (timeout_us /1000000 ); +return 0 ; + } + size =colo_proxy_recv (cps, &buff, timeout_us);/* timeout, return no checkpoint message. */
tools/libxl/libxl_colo_save.c +7 -2
@@ -110,8 +110,13 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) css->colo_proxy_script =GCSPRINTF ("%s/colo-proxy-setup" ,libxl__xen_script_dir_path ()); - cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VIF ) | - (1 <<LIBXL__DEVICE_KIND_VBD ); +/* If enable userspace proxy mode, we don't need VIF */ +if (css->cps.is_userspace_proxy) + cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VBD ); +else + cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VIF ) | + (1 <<LIBXL__DEVICE_KIND_VBD ); + cds->ops = colo_ops; cds->callback = colo_save_setup_done; cds->ao = ao;
Signature · 9 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH V3 2/7] COLO-Proxy: Setup userspace colo-proxy on primary side
Quoted 52 lines · Zhang Chen
In this patch we close kernel COLO-Proxy on primary side.
Signed-off-by Zhang Chen <[email protected]>--- tools/libxl/libxl_colo_proxy.c | 27 +++++++++++++++++++++++++++ tools/libxl/libxl_colo_save.c | 9 +++++++-- 2 files changed, 34 insertions(+), 2 deletions(-)tools/libxl/libxl_colo_proxy.c +18
-0@@ -152,6 +152,10 @@ int colo_proxy_setup(libxl__colo_proxy_state *cps)STATE_AO_GC (cps->ao); +/* If enable userspace proxy mode, we don't need setup kernel proxy */ +if (cps->is_userspace_proxy) +return 0 ; + skfd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_COLO );if (skfd <0 ) {LOGD (ERROR , ao->domid,"can not create a netlink socket: %s" ,strerror (errno));@@ -222,6 +226,13 @@ out:void colo_proxy_teardown (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need teardown kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +if (cps->sock_fd >=0 ) {close (cps->sock_fd); cps->sock_fd =-1 ;@@ -232,6 +243,13 @@ void colo_proxy_teardown(libxl__colo_proxy_state *cps)void colo_proxy_preresume (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need preresume kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +colo_proxy_send (cps,NULL ,0 ,COLO_CHECKPOINT );/* TODO: need to handle if the call fails... */ }
tools/libxl/libxl_colo_proxy.c int colo_proxy_checkpoint(libxl__colo_proxy_state *cps, · line 288
Quoted 9 lines
tools/libxl/libxl_colo_proxy.c +6
-0@@ -262,6 +280,15 @@ int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,STATE_AO_GC (cps->ao); +/* +* enable userspace proxy mode, tmp sleep. +* then we will add qemu API support this func. +*/ +if (cps->is_userspace_proxy) { +sleep (timeout_us /1000000 );
usleep is better.
But in general I don't think sleeping in libxl is a good idea. What is the reason that you need to sleep here?
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH V3 2/7] COLO-Proxy: Setup userspace colo-proxy on primary side
Quoted 56 lines · Wei Liu
Quoted 55 lines · Zhang Chen
In this patch we close kernel COLO-Proxy on primary side.
Signed-off-by Zhang Chen <[email protected]>--- tools/libxl/libxl_colo_proxy.c | 27 +++++++++++++++++++++++++++ tools/libxl/libxl_colo_save.c | 9 +++++++-- 2 files changed, 34 insertions(+), 2 deletions(-)tools/libxl/libxl_colo_proxy.c +18
-0@@ -152,6 +152,10 @@ int colo_proxy_setup(libxl__colo_proxy_state *cps)STATE_AO_GC (cps->ao); +/* If enable userspace proxy mode, we don't need setup kernel proxy */ +if (cps->is_userspace_proxy) +return 0 ; + skfd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_COLO );if (skfd <0 ) {LOGD (ERROR , ao->domid,"can not create a netlink socket: %s" ,strerror (errno));@@ -222,6 +226,13 @@ out:void colo_proxy_teardown (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need teardown kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +if (cps->sock_fd >=0 ) {close (cps->sock_fd); cps->sock_fd =-1 ;@@ -232,6 +243,13 @@ void colo_proxy_teardown(libxl__colo_proxy_state *cps)void colo_proxy_preresume (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need preresume kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +colo_proxy_send (cps,NULL ,0 ,COLO_CHECKPOINT );/* TODO: need to handle if the call fails... */ }@@ -262,6 +280,15 @@ int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,STATE_AO_GC (cps->ao);
Quoted 7 lines
tools/libxl/libxl_colo_proxy.c int colo_proxy_checkpoint(libxl__colo_proxy_state *cps, · line 288
Quoted 6 lines
tools/libxl/libxl_colo_proxy.c +6
-0+/* +* enable userspace proxy mode, tmp sleep. +* then we will add qemu API support this func. +*/ +if (cps->is_userspace_proxy) { +sleep (timeout_us /1000000 );usleep is better.
OK.
Quoted 3 lines
But in general I don't think sleeping in libxl is a good idea. What is the reason that you need to sleep here?
In here we use this sleep to keep COLO period checkpoint,
We can not do checkpoint continuously, that will make performance poor. After 7/7 we change this to
ret = colo_userspace_proxy_recv(cps, recvbuff, timeout_us);
Thanks
Zhang Chen
Quoted 6 lines
Wei.
.
Signature · 10 lines
Thanks Zhang Chen _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH V3 2/7] COLO-Proxy: Setup userspace colo-proxy on primary side
Quoted 64 lines · Zhang Chen
Quoted 49 lines · Wei Liu
Quoted 48 lines · Zhang Chen
In this patch we close kernel COLO-Proxy on primary side.
Signed-off-by Zhang Chen <[email protected]>--- tools/libxl/libxl_colo_proxy.c | 27 +++++++++++++++++++++++++++ tools/libxl/libxl_colo_save.c | 9 +++++++-- 2 files changed, 34 insertions(+), 2 deletions(-)tools/libxl/libxl_colo_proxy.c +18
-0@@ -152,6 +152,10 @@ int colo_proxy_setup(libxl__colo_proxy_state *cps)STATE_AO_GC (cps->ao); +/* If enable userspace proxy mode, we don't need setup kernel proxy */ +if (cps->is_userspace_proxy) +return 0 ; + skfd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_COLO );if (skfd <0 ) {LOGD (ERROR , ao->domid,"can not create a netlink socket: %s" ,strerror (errno));@@ -222,6 +226,13 @@ out:void colo_proxy_teardown (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need teardown kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +if (cps->sock_fd >=0 ) {close (cps->sock_fd); cps->sock_fd =-1 ;@@ -232,6 +243,13 @@ void colo_proxy_teardown(libxl__colo_proxy_state *cps)void colo_proxy_preresume (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need preresume kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +colo_proxy_send (cps,NULL ,0 ,COLO_CHECKPOINT );/* TODO: need to handle if the call fails... */ }@@ -262,6 +280,15 @@ int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,Quoted 8 lines
tools/libxl/libxl_colo_proxy.c int colo_proxy_checkpoint(libxl__colo_proxy_state *cps, · line 288
Quoted 7 lines
tools/libxl/libxl_colo_proxy.c +6
-0STATE_AO_GC (cps->ao); +/* +* enable userspace proxy mode, tmp sleep. +* then we will add qemu API support this func. +*/ +if (cps->is_userspace_proxy) { +sleep (timeout_us /1000000 );usleep is better.
OK.
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
But in general I don't think sleeping in libxl is a good idea. What is the reason that you need to sleep here?
In here we use this sleep to keep COLO period checkpoint,
We can not do checkpoint continuously, that will make performance poor. After 7/7 we change this to
ret =colo_userspace_proxy_recv(cps, recvbuff, timeout_us);
I don't fully understand. Say, if I just use COLO with this sleep, will it work?
Quoted 4 lines
Thanks
Zhang ChenQuoted 1 line
Quoted 12 lines
Quoted 5 lines
Wei.
.
Signature · 2 lines
Thanks Zhang Chen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH V3 2/7] COLO-Proxy: Setup userspace colo-proxy on primary side
Quoted 64 lines · Wei Liu
Quoted 63 lines · Zhang Chen
Quoted 49 lines · Wei Liu
Quoted 48 lines · Zhang Chen
In this patch we close kernel COLO-Proxy on primary side.
Signed-off-by Zhang Chen <[email protected]>--- tools/libxl/libxl_colo_proxy.c | 27 +++++++++++++++++++++++++++ tools/libxl/libxl_colo_save.c | 9 +++++++-- 2 files changed, 34 insertions(+), 2 deletions(-)tools/libxl/libxl_colo_proxy.c +18
-0@@ -152,6 +152,10 @@ int colo_proxy_setup(libxl__colo_proxy_state *cps)STATE_AO_GC (cps->ao); +/* If enable userspace proxy mode, we don't need setup kernel proxy */ +if (cps->is_userspace_proxy) +return 0 ; + skfd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_COLO );if (skfd <0 ) {LOGD (ERROR , ao->domid,"can not create a netlink socket: %s" ,strerror (errno));@@ -222,6 +226,13 @@ out:void colo_proxy_teardown (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need teardown kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +if (cps->sock_fd >=0 ) {close (cps->sock_fd); cps->sock_fd =-1 ;@@ -232,6 +243,13 @@ void colo_proxy_teardown(libxl__colo_proxy_state *cps)void colo_proxy_preresume (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need preresume kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +colo_proxy_send (cps,NULL ,0 ,COLO_CHECKPOINT );/* TODO: need to handle if the call fails... */ }@@ -262,6 +280,15 @@ int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,Quoted 8 lines
tools/libxl/libxl_colo_proxy.c int colo_proxy_checkpoint(libxl__colo_proxy_state *cps, · line 288
Quoted 7 lines
tools/libxl/libxl_colo_proxy.c +6
-0STATE_AO_GC (cps->ao); +/* +* enable userspace proxy mode, tmp sleep. +* then we will add qemu API support this func. +*/ +if (cps->is_userspace_proxy) { +sleep (timeout_us /1000000 );usleep is better.
OK.
Quoted 2 lines
But in general I don't think sleeping in libxl is a good idea. What is the reason that you need to sleep here?
Quoted 7 lines
Quoted 5 lines
In here we use this sleep to keep COLO period checkpoint,
We can not do checkpoint continuously, that will make performance poor. After 7/7 we change this to
ret =colo_userspace_proxy_recv(cps, recvbuff, timeout_us);I don't fully understand. Say, if I just use COLO with this sleep, will it work?
Yes, but COLO just have period checkpoint.
for example, in this mode, we set 10 sec to do one checkpoint,
the guest's net packet will be buffered 0-10 sec before send to client.because we must ensure primary guest status same with secondary guest(need do a checkpoint), When we have colo-compare, if primary guest's packet same with secondary guest's packet we send packet to client immediately,
else have different packet we alse send packet to client immediately and with a checkpoint notify to colo-frame. That's make colo performance greater than period mode.
Thanks
Zhang Chen
Quoted 18 lines
Quoted 15 lines
Thanks
Zhang ChenQuoted 5 lines
Wei.
.
Signature · 2 lines
Thanks Zhang Chen.
Signature · 10 lines
Thanks Zhang Chen _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH V3 2/7] COLO-Proxy: Setup userspace colo-proxy on primary side
Quoted 75 lines · Zhang Chen
Quoted 64 lines · Wei Liu
Quoted 63 lines · Zhang Chen
Quoted 49 lines · Wei Liu
Quoted 48 lines · Zhang Chen
In this patch we close kernel COLO-Proxy on primary side.
Signed-off-by Zhang Chen <[email protected]>--- tools/libxl/libxl_colo_proxy.c | 27 +++++++++++++++++++++++++++ tools/libxl/libxl_colo_save.c | 9 +++++++-- 2 files changed, 34 insertions(+), 2 deletions(-)tools/libxl/libxl_colo_proxy.c +18
-0@@ -152,6 +152,10 @@ int colo_proxy_setup(libxl__colo_proxy_state *cps)STATE_AO_GC (cps->ao); +/* If enable userspace proxy mode, we don't need setup kernel proxy */ +if (cps->is_userspace_proxy) +return 0 ; + skfd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_COLO );if (skfd <0 ) {LOGD (ERROR , ao->domid,"can not create a netlink socket: %s" ,strerror (errno));@@ -222,6 +226,13 @@ out:void colo_proxy_teardown (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need teardown kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +if (cps->sock_fd >=0 ) {close (cps->sock_fd); cps->sock_fd =-1 ;@@ -232,6 +243,13 @@ void colo_proxy_teardown(libxl__colo_proxy_state *cps)void colo_proxy_preresume (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need preresume kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +colo_proxy_send (cps,NULL ,0 ,COLO_CHECKPOINT );/* TODO: need to handle if the call fails... */ }@@ -262,6 +280,15 @@ int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,Quoted 8 lines
tools/libxl/libxl_colo_proxy.c int colo_proxy_checkpoint(libxl__colo_proxy_state *cps, · line 288
Quoted 7 lines
tools/libxl/libxl_colo_proxy.c +6
-0STATE_AO_GC (cps->ao); +/* +* enable userspace proxy mode, tmp sleep. +* then we will add qemu API support this func. +*/ +if (cps->is_userspace_proxy) { +sleep (timeout_us /1000000 );usleep is better.
OK.
Quoted 2 lines
But in general I don't think sleeping in libxl is a good idea. What is the reason that you need to sleep here?
Quoted 7 lines
Quoted 5 lines
In here we use this sleep to keep COLO period checkpoint,
We can not do checkpoint continuously, that will make performance poor. After 7/7 we change this to
ret =colo_userspace_proxy_recv(cps, recvbuff, timeout_us);I don't fully understand. Say, if I just use COLO with this sleep, will it work?
Quoted 11 lines
Yes, but COLO just have period checkpoint.
for example, in this mode, we set 10 sec to do one checkpoint, the guest's net packet will be buffered 0-10 sec before send to client.because we must ensure primary guest status same with secondary guest(need do a checkpoint), When we have colo-compare, if primary guest's packet same
with secondary guest's packet we send packet to client immediately, else have different packet we alse send packet to client immediately and with a checkpoint notify to colo-frame. That's make colo performance greater than period mode.
OK, in short, this is for periodical checkpoint mode. I still think it is a bad idea to invoke (u)sleep in libxl, but since you're going to remove it anyway, there is no point in making things more complicated than necessary.
But I want to suggest you improve the comment a bit.
1. Properly capitalise the sentence.
2. Replace "tmp sleep" with "sleeping temporarily for XXX mode".
3. Clarify the QEMU API part (why is that relevant to the sleep or whatever comes next).
I don't like to nit-pick too much about language, but keep in mind that other people may want to contribute to COLO project so it is important to have comments as accurate and clear as possible.
Wei.
Quoted 20 lines
Thanks
Zhang ChenQuoted 16 lines
Quoted 15 lines
Thanks
Zhang ChenQuoted 5 lines
Wei.
.
Signature · 2 lines
Thanks Zhang Chen
Quoted 9 lines
Quoted 2 lines
.
Signature · 2 lines
Thanks Zhang Chen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH V3 2/7] COLO-Proxy: Setup userspace colo-proxy on primary side
Quoted 91 lines · Wei Liu
Quoted 72 lines · Zhang Chen
Quoted 63 lines · Wei Liu
Quoted 62 lines · Zhang Chen
Quoted 49 lines · Wei Liu
Quoted 48 lines · Zhang Chen
In this patch we close kernel COLO-Proxy on primary side.
Signed-off-by Zhang Chen <[email protected]>--- tools/libxl/libxl_colo_proxy.c | 27 +++++++++++++++++++++++++++ tools/libxl/libxl_colo_save.c | 9 +++++++-- 2 files changed, 34 insertions(+), 2 deletions(-)tools/libxl/libxl_colo_proxy.c +18
-0@@ -152,6 +152,10 @@ int colo_proxy_setup(libxl__colo_proxy_state *cps)STATE_AO_GC (cps->ao); +/* If enable userspace proxy mode, we don't need setup kernel proxy */ +if (cps->is_userspace_proxy) +return 0 ; + skfd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_COLO );if (skfd <0 ) {LOGD (ERROR , ao->domid,"can not create a netlink socket: %s" ,strerror (errno));@@ -222,6 +226,13 @@ out:void colo_proxy_teardown (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need teardown kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +if (cps->sock_fd >=0 ) {close (cps->sock_fd); cps->sock_fd =-1 ;@@ -232,6 +243,13 @@ void colo_proxy_teardown(libxl__colo_proxy_state *cps)void colo_proxy_preresume (libxl__colo_proxy_state *cps) { +/* +* If enable userspace proxy mode, +* we don't need preresume kernel proxy +*/ +if (cps->is_userspace_proxy) +return ; +colo_proxy_send (cps,NULL ,0 ,COLO_CHECKPOINT );/* TODO: need to handle if the call fails... */ }@@ -262,6 +280,15 @@ int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,Quoted 8 lines
tools/libxl/libxl_colo_proxy.c int colo_proxy_checkpoint(libxl__colo_proxy_state *cps, · line 288
Quoted 7 lines
tools/libxl/libxl_colo_proxy.c +6
-0STATE_AO_GC (cps->ao); +/* +* enable userspace proxy mode, tmp sleep. +* then we will add qemu API support this func. +*/ +if (cps->is_userspace_proxy) { +sleep (timeout_us /1000000 );usleep is better.
OK.
Quoted 2 lines
But in general I don't think sleeping in libxl is a good idea. What is the reason that you need to sleep here?
Quoted 7 lines
Quoted 5 lines
In here we use this sleep to keep COLO period checkpoint,
We can not do checkpoint continuously, that will make performance poor. After 7/7 we change this to
ret =colo_userspace_proxy_recv(cps, recvbuff, timeout_us);I don't fully understand. Say, if I just use COLO with this sleep, will it work?
Quoted 11 lines
Yes, but COLO just have period checkpoint.
for example, in this mode, we set 10 sec to do one checkpoint, the guest's net packet will be buffered 0-10 sec before send to client.because we must ensure primary guest status same with secondary guest(need do a checkpoint), When we have colo-compare, if primary guest's packet same
with secondary guest's packet we send packet to client immediately, else have different packet we alse send packet to client immediately and with a checkpoint notify to colo-frame. That's make colo performance greater than period mode.OK, in short, this is for periodical checkpoint mode. I still think it is a bad idea to invoke (u)sleep in libxl, but since you're going to remove it anyway, there is no point in making things more complicated than necessary.
But I want to suggest you improve the comment a bit.
Quoted 8 lines
1. Properly capitalise the sentence.
2. Replace "tmp sleep" with "sleeping temporarily for XXX mode".
3. Clarify the QEMU API part (why is that relevant to the sleep or whatever comes next).I don't like to nit-pick too much about language, but keep in mind that other people may want to contribute to COLO project so it is important to have comments as accurate and clear as possible.
Make sense. I will add more comments in next version.
Thanks
Zhang Chen
Quoted 31 lines
Wei.
Quoted 11 lines
Thanks
Zhang ChenQuoted 8 lines
Quoted 8 lines
Thanks
Zhang ChenQuoted 5 lines
Wei.
.
Quoted 14 lines
Quoted 8 lines
Quoted 6 lines
Signature · 2 lines
Thanks Zhang Chen.
Signature · 2 lines
Thanks Zhang Chen.
Signature · 10 lines
Thanks Zhang Chen _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 3/7 tools/libxl: refactor do_domain_create()
In reply to Zhang ChenWe use params->colo_proxy_script to make do_domain_create() doesn't take "colo_proxy_script" anymore.
--- tools/libxl/libxl_create.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
tools/libxl/libxl_create.c +10 -7
@@ -1608,7 +1608,6 @@ static void domain_create_cb(libxl__egc *egc,static int do_domain_create (libxl_ctx *ctx,libxl_domain_config *d_config,uint32_t *domid,int restore_fd,int send_back_fd,const libxl_domain_restore_params *params, -const char *colo_proxy_script,const libxl_asyncop_how *ao_how,const libxl_asyncprogress_how *aop_console_how) {
@@ -1632,7 +1631,14 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, } cdcs->dcs.callback = domain_create_cb; cdcs->dcs.domid_soft_reset =INVALID_DOMID ; - cdcs->dcs.colo_proxy_script = colo_proxy_script; + +if (cdcs->dcs.restore_params.checkpointed_stream == +LIBXL_CHECKPOINTED_STREAM_COLO ) + cdcs->dcs.colo_proxy_script = + cdcs->dcs.restore_params.colo_proxy_script; +else + cdcs->dcs.colo_proxy_script =NULL ; +libxl__ao_progress_gethow (&cdcs->dcs.aop_console_how, aop_console_how); cdcs->domid_out = domid;
@@ -1820,7 +1826,7 @@ int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, const libxl_asyncprogress_how *aop_console_how) {unset_disk_colo_restore (d_config); -return do_domain_create (ctx, d_config, domid,-1 ,-1 ,NULL ,NULL , +return do_domain_create (ctx, d_config, domid,-1 ,-1 ,NULL , ao_how, aop_console_how); }
@@ -1831,17 +1837,14 @@ int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,const libxl_asyncop_how *ao_how, const libxl_asyncprogress_how *aop_console_how) { - char *colo_proxy_script = NULL; - if (params->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_COLO) { - colo_proxy_script = params->colo_proxy_script;set_disk_colo_restore (d_config ); } else {unset_disk_colo_restore (d_config); }return do_domain_create (ctx, d_config, domid, restore_fd, send_back_fd, - params, colo_proxy_script, ao_how, aop_console_how); + params, ao_how, aop_console_how); } int libxl_domain_soft_reset(libxl_ctx *ctx,
Signature · 9 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH V3 3/7] tools/libxl: refactor do_domain_create()
Quoted 5 lines · Zhang Chen
We use
params->colo_proxy_scriptto makedo_domain_create()doesn't take "colo_proxy_script" anymore.Signed-off-by Zhang Chen <[email protected]>---
This patch is self-contained so:
I will commit this soon. Please rebase your next version against staging.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH V3 3/7] tools/libxl: refactor do_domain_create()
Quoted 4 lines · Wei Liu
Quoted 3 lines · Zhang Chen
We use
params->colo_proxy_scriptto makedo_domain_create()doesn't take "colo_proxy_script" anymore.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Zhang Chen <[email protected]>---
This patch is self-contained so:
Acked-by Wei Liu <[email protected]>I will commit this soon. Please rebase your next version against staging.
OK
Thanks
Zhang Chen
Quoted 6 lines
Wei.
.
Signature · 10 lines
Thanks Zhang Chen _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 4/7 COLO-Proxy: Setup userspace colo-proxy on secondary side
In reply to Zhang ChenIn this patch we add a function to close COLO kernel Proxy on secondary side.
--- tools/libxl/libxl_colo_restore.c | 8 ++++++-- tools/libxl/libxl_create.c | 8 ++++++-- tools/libxl/libxl_types.idl | 1 + tools/libxl/xl_cmdimpl.c | 18 +++++++++++++++--- 4 files changed, 28 insertions(+), 7 deletions(-)
tools/libxl/libxl_colo_restore.c +6 -2
@@ -774,8 +774,12 @@ static void colo_setup_checkpoint_devices(libxl__egc *egc,STATE_AO_GC (crs->ao); - cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VIF ) | - (1 <<LIBXL__DEVICE_KIND_VBD ); +if (crs->cps.is_userspace_proxy) + cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VBD ); +else + cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VIF ) | + (1 <<LIBXL__DEVICE_KIND_VBD ); + cds->callback = colo_restore_setup_cds_done; cds->ao = ao; cds->domid = crs->domid;
tools/libxl/libxl_create.c +6 -2
@@ -1633,11 +1633,15 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, cdcs->dcs.domid_soft_reset =INVALID_DOMID ;if (cdcs->dcs.restore_params.checkpointed_stream == -LIBXL_CHECKPOINTED_STREAM_COLO ) +LIBXL_CHECKPOINTED_STREAM_COLO ) { cdcs->dcs.colo_proxy_script = cdcs->dcs.restore_params.colo_proxy_script; -else + cdcs->dcs.crs.cps.is_userspace_proxy = +libxl_defbool_val (cdcs->dcs.restore_params.userspace_colo_proxy); + }else { cdcs->dcs.colo_proxy_script =NULL ; + cdcs->dcs.crs.cps.is_userspace_proxy = false; + }libxl__ao_progress_gethow (&cdcs->dcs.aop_console_how, aop_console_how); cdcs->domid_out = domid;
tools/libxl/libxl_types.idl +1 -0
@@ -390,6 +390,7 @@ libxl_domain_restore_params = Struct("domain_restore_params", [ ("checkpointed_stream", integer), ("stream_version", uint32, {'init_val': '1'}), ("colo_proxy_script", string), + ("userspace_colo_proxy", libxl_defbool), ]) libxl_sched_params = Struct("sched_params",[
tools/libxl/xl_cmdimpl.c +15 -3
@@ -162,6 +162,7 @@ struct domain_create {char *extra_config;/* extra config string */ const char *restore_file;char *colo_proxy_script; +bool userspace_colo_proxy;int migrate_fd;/* -1 means none */ int send_back_fd;/* -1 means none */ char **migration_domname_r;/* from malloc */
@@ -3024,6 +3025,8 @@ start: params.stream_version = (hdr.mandatory_flags & XL_MANDATORY_FLAG_STREAMv2) ?2 :1 ; params.colo_proxy_script = dom_info->colo_proxy_script; +libxl_defbool_set (¶ms.userspace_colo_proxy, + dom_info->userspace_colo_proxy); ret = libxl_domain_create_restore(ctx, &d_config, &domid, restore_fd,
@@ -4824,7 +4827,8 @@ static void migrate_receive(int debug, int daemonize, int monitor,int pause_after_migration, int send_fd, int recv_fd, libxl_checkpointed_stream checkpointed, - char *colo_proxy_script) + char *colo_proxy_script, + bool userspace_colo_proxy) { uint32_t domid;int rc, rc2;
@@ -4852,6 +4856,7 @@ static void migrate_receive(int debug, int daemonize, int monitor, dom_info.migration_domname_r = &migration_domname; dom_info.checkpointed_stream = checkpointed; dom_info.colo_proxy_script = colo_proxy_script; + dom_info.userspace_colo_proxy = userspace_colo_proxy; rc =create_domain (&dom_info);if (rc <0 ) {
@@ -5051,11 +5056,13 @@ int main_migrate_receive(int argc, char **argv)int debug =0 , daemonize =1 , monitor =1 , pause_after_migration =0 ;libxl_checkpointed_stream checkpointed =LIBXL_CHECKPOINTED_STREAM_NONE ;int opt; +bool userspace_colo_proxy = false;char *script =NULL ;static struct option opts[] = { {"colo" ,0 ,0 ,0x100 },/* It is a shame that the management code for disk is not here. */ {"coloft-script" ,1 ,0 ,0x200 }, + {"userspace-colo-proxy" ,0 ,0 ,0x300 },COMMON_LONG_OPTS };
@@ -5079,6 +5086,9 @@ int main_migrate_receive(int argc, char **argv)case 0x200 : script = optarg;break ; +case 0x300 : + userspace_colo_proxy = true; +break ;case 'p' : pause_after_migration =1 ;break ;
@@ -5090,7 +5100,7 @@ int main_migrate_receive(int argc, char **argv) }migrate_receive (debug, daemonize, monitor, pause_after_migration,STDOUT_FILENO ,STDIN_FILENO , - checkpointed, script); + checkpointed, script, userspace_colo_proxy);return EXIT_SUCCESS ; }
@@ -8984,11 +8994,13 @@ int main_remus(int argc, char **argv)"-r" , daemonize ? "" : " -e"); }else { -xasprintf (&rune,"exec %s %s xl migrate-receive %s %s %s %s" , +xasprintf (&rune,"exec %s %s xl migrate-receive %s %s %s %s %s" , ssh_command, host,"--colo" , r_info.netbufscript ?"--coloft-script" :"" , r_info.netbufscript ? r_info.netbufscript :"" , +libxl_defbool_val (r_info.userspace_colo_proxy) ? +"--userspace-colo-proxy" :"" , daemonize ?"" :" -e" ); } }
Signature · 9 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 5/7 COLO-Proxy: Add primary userspace colo proxy start args
In reply to Zhang ChenQemu need this args to start userspace colo-proxy.
--- tools/libxl/libxl_dm.c | 98 +++++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_nic.c | 78 ++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_types.idl | 31 +++++++++++++- tools/libxl/xl_cmdimpl.c | 58 +++++++++++++++++++++++++++ 4 files changed, 264 insertions(+), 1 deletion(-)
tools/libxl/libxl_dm.c +98 -0
@@ -1244,7 +1244,105 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, nics[i].devid, ifname,libxl_tapif_script (gc), libxl_tapif_script(gc))); + +/* Userspace COLO Proxy need this */ +#define APPEND_COLO_SOCK_SERVER (sock_id, sock_ip, sock_port) ({ \ + if (nics[i].colo_##sock_id && \ + nics[i].colo_##sock_ip && \ + nics[i].colo_##sock_port) { \ + flexarray_append(dm_args, "-chardev"); \ + flexarray_append(dm_args, \ + GCSPRINTF("socket,id=%s,host=%s,port=%s,server,nowait", \ + nics[i].colo_##sock_id, \ + nics[i].colo_##sock_ip, \ + nics[i].colo_##sock_port)); \ + } \ +}) + +#define APPEND_COLO_SOCK_CLIENT (sock_id, sock_ip, sock_port) ({ \ + if (nics[i].colo_##sock_id && \ + nics[i].colo_##sock_ip && \ + nics[i].colo_##sock_port) { \ + flexarray_append(dm_args, "-chardev"); \ + flexarray_append(dm_args, \ + GCSPRINTF("socket,id=%s,host=%s,port=%s", \ + nics[i].colo_##sock_id, \ + nics[i].colo_##sock_ip, \ + nics[i].colo_##sock_port)); \ + } \ +}) + +if (state->saved_state) { +/* secondary colo run */ + }else { +/* primary colo run */ + +APPEND_COLO_SOCK_SERVER (sock_mirror_id, + sock_mirror_ip, + sock_mirror_port); + +APPEND_COLO_SOCK_SERVER (sock_compare_pri_in_id, + sock_compare_pri_in_ip, + sock_compare_pri_in_port); + +APPEND_COLO_SOCK_SERVER (sock_compare_sec_in_id, + sock_compare_sec_in_ip, + sock_compare_sec_in_port); + +APPEND_COLO_SOCK_SERVER (sock_redirector0_id, + sock_redirector0_ip, + sock_redirector0_port); + +APPEND_COLO_SOCK_CLIENT (sock_redirector1_id, + sock_redirector1_ip, + sock_redirector1_port); + +APPEND_COLO_SOCK_CLIENT (sock_redirector2_id, + sock_redirector2_ip, + sock_redirector2_port); + +if (nics[i].colo_filter_mirror_queue && + nics[i].colo_filter_mirror_outdev) { +flexarray_append (dm_args,"-object" ); +flexarray_append (dm_args, +GCSPRINTF ("filter-mirror,id=m1,netdev=net%d,queue=%s,outdev=%s" , + nics[i].devid, + nics[i].colo_filter_mirror_queue, + nics[i].colo_filter_mirror_outdev)); + } +if (nics[i].colo_filter_redirector0_queue && + nics[i].colo_filter_redirector0_indev) { +flexarray_append (dm_args,"-object" ); +flexarray_append (dm_args, +GCSPRINTF ("filter-redirector,id=r1,netdev=net%d,queue=%s,indev=%s" , + nics[i].devid, + nics[i].colo_filter_redirector0_queue, + nics[i].colo_filter_redirector0_indev)); + } +if (nics[i].colo_filter_redirector1_queue && + nics[i].colo_filter_redirector1_outdev) { +flexarray_append (dm_args,"-object" ); +flexarray_append (dm_args, +GCSPRINTF ("filter-redirector,id=r2,netdev=net%d,queue=%s,outdev=%s" , + nics[i].devid, + nics[i].colo_filter_redirector1_queue, + nics[i].colo_filter_redirector1_outdev)); + } +if (nics[i].colo_compare_pri_in && + nics[i].colo_compare_sec_in && + nics[i].colo_compare_out) { +flexarray_append (dm_args,"-object" ); +flexarray_append (dm_args, +GCSPRINTF ("colo-compare,id=c1,primary_in=%s,secondary_in=%s,outdev=%s" , + nics[i].colo_compare_pri_in, + nics[i].colo_compare_sec_in, + nics[i].colo_compare_out)); + } + } ioemu_nics++; + +#undef APPEND_COLO_SOCK_SERVER +#undef APPEND_COLO_SOCK_CLIENT } }/* If we have no emulated nics, tell qemu not to create any */
tools/libxl/libxl_nic.c +78 -0
90 lines not on this page · raw message
tools/libxl/libxl_types.idl +30 -1
@@ -629,7 +629,36 @@ libxl_device_nic = Struct("device_nic", [ ("gatewaydev", string), # Note that the COLO configuration settings should be considered unstable. # They may change incompatibly in future versions of Xen. - ("coloft_forwarddev", string) + ("coloft_forwarddev", string), + ("colo_sock_mirror_id", string), + ("colo_sock_mirror_ip", string), + ("colo_sock_mirror_port", string), + ("colo_sock_compare_pri_in_id", string), + ("colo_sock_compare_pri_in_ip", string), + ("colo_sock_compare_pri_in_port", string), + ("colo_sock_compare_sec_in_id", string), + ("colo_sock_compare_sec_in_ip", string), + ("colo_sock_compare_sec_in_port", string), + ("colo_sock_redirector0_id", string), + ("colo_sock_redirector0_ip", string), + ("colo_sock_redirector0_port", string), + ("colo_sock_redirector1_id", string), + ("colo_sock_redirector1_ip", string), + ("colo_sock_redirector1_port", string), + ("colo_sock_redirector2_id", string), + ("colo_sock_redirector2_ip", string), + ("colo_sock_redirector2_port", string), + ("colo_filter_mirror_queue", string), + ("colo_filter_mirror_outdev", string), + ("colo_filter_redirector0_queue", string), + ("colo_filter_redirector0_indev", string), + ("colo_filter_redirector0_outdev", string), + ("colo_filter_redirector1_queue", string), + ("colo_filter_redirector1_indev", string), + ("colo_filter_redirector1_outdev", string), + ("colo_compare_pri_in", string), + ("colo_compare_sec_in", string), + ("colo_compare_out", string) ]) libxl_device_pci = Struct("device_pci", [
tools/libxl/xl_cmdimpl.c +58 -0
64 lines not on this page · raw message
Signature · 9 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH V3 5/7] COLO-Proxy: Add primary userspace colo proxy start args
Quoted 3 lines · Zhang Chen
Qemu need this args to start userspace colo-proxy.
Signed-off-by Zhang Chen <[email protected]>
[...]
tools/libxl/libxl_dm.c static int libxl__build_device_model_args_new(libxl__gc *gc, · line 1345
Quoted 3 lines
tools/libxl/libxl_dm.c +3
-0+ +#undef APPEND_COLO_SOCK_SERVER +#undef APPEND_COLO_SOCK_CLIENT
I would move these a bit further up, right after the last site that uses them.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH V3 5/7] COLO-Proxy: Add primary userspace colo proxy start args
Quoted 10 lines · Wei Liu
Quoted 3 lines · Zhang Chen
Qemu need this args to start userspace colo-proxy.
Signed-off-by Zhang Chen <[email protected]>[...]
tools/libxl/libxl_dm.c static int libxl__build_device_model_args_new(libxl__gc *gc, · line 1345
Quoted 3 lines
tools/libxl/libxl_dm.c +3
-0+ +#undef APPEND_COLO_SOCK_SERVER +#undef APPEND_COLO_SOCK_CLIENTI would move these a bit further up, right after the last site that uses them.
How about move it to here?
} else {
if (!sdl && !vnc) {
flexarray_append(dm_args, "-nographic");
}
}+#undef APPEND_COLO_SOCK_SERVER
+#undef APPEND_COLO_SOCK_CLIENT
if (state->saved_state) {
/* This file descriptor is meant to be used by QEMU */
*dm_state_fd = open(state->saved_state, O_RDONLY);
flexarray_append(dm_args, "-incoming");
flexarray_append(dm_args, GCSPRINTF("fd:%d",*dm_state_fd));
}Thanks
Zhang Chen
Quoted 6 lines
Wei.
.
Signature · 10 lines
Thanks Zhang Chen _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH V3 5/7] COLO-Proxy: Add primary userspace colo proxy start args
Quoted 23 lines · Zhang Chen
Quoted 10 lines · Wei Liu
Quoted 3 lines · Zhang Chen
Qemu need this args to start userspace colo-proxy.
Signed-off-by Zhang Chen <[email protected]>[...]
tools/libxl/libxl_dm.c static int libxl__build_device_model_args_new(libxl__gc *gc, · line 1345
Quoted 3 lines
tools/libxl/libxl_dm.c +3
-0+ +#undef APPEND_COLO_SOCK_SERVER +#undef APPEND_COLO_SOCK_CLIENTI would move these a bit further up, right after the last site that uses them.
How about move it to here?
} else { if (!sdl && !vnc) { flexarray_append(dm_args, "-nographic"); } }
Review
Quoted 10 lines
(quoted diff) +2
-0+#undef APPEND_COLO_SOCK_SERVER +#undef APPEND_COLO_SOCK_CLIENT if (state->saved_state) { /* This file descriptor is meant to be used by QEMU */ *dm_state_fd = open(state->saved_state, O_RDONLY); flexarray_append(dm_args, "-incoming"); flexarray_append(dm_args, GCSPRINTF("fd:%d",*dm_state_fd)); }
I can't seem to find this context.
But, after thinking a bit more I think you can leave those in their original position. That's just a trivial issue. I don't want to spend too much time bikeshedding.
Wei.
Quoted 5 lines
Thanks
Zhang ChenQuoted 1 line
Quoted 12 lines
Quoted 5 lines
Wei.
.
Signature · 2 lines
Thanks Zhang Chen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v3 6/7 COLO-Proxy: Add secondary userspace colo-proxy start args
In reply to Zhang ChenQemu need this args to start userspace colo-proxy.
--- tools/libxl/libxl_dm.c | 34 ++++++++++++++++++++++++++++++++++ tools/libxl/libxl_nic.c | 27 +++++++++++++++++++++++++++ tools/libxl/libxl_types.idl | 15 ++++++++++++++- tools/libxl/xl_cmdimpl.c | 27 +++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 1 deletion(-)
tools/libxl/libxl_dm.c +34 -0
@@ -1274,6 +1274,40 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,if (state->saved_state) {/* secondary colo run */ + +APPEND_COLO_SOCK_CLIENT (sock_sec_redirector0_id, + sock_sec_redirector0_ip, + sock_sec_redirector0_port); + +APPEND_COLO_SOCK_CLIENT (sock_sec_redirector1_id, + sock_sec_redirector1_ip, + sock_sec_redirector1_port); + +if (nics[i].colo_filter_sec_redirector0_queue && + nics[i].colo_filter_sec_redirector0_indev) { +flexarray_append (dm_args,"-object" ); +flexarray_append (dm_args, +GCSPRINTF ("filter-redirector,id=rs1,netdev=net%d,queue=%s,indev=%s" , + nics[i].devid, + nics[i].colo_filter_sec_redirector0_queue, + nics[i].colo_filter_sec_redirector0_indev)); + } +if (nics[i].colo_filter_sec_redirector1_queue && + nics[i].colo_filter_sec_redirector1_indev) { +flexarray_append (dm_args,"-object" ); +flexarray_append (dm_args, +GCSPRINTF ("filter-redirector,id=rs2,netdev=net%d,queue=%s,outdev=%s" , + nics[i].devid, + nics[i].colo_filter_sec_redirector1_queue, + nics[i].colo_filter_sec_redirector1_outdev)); + } +if (nics[i].colo_filter_sec_rewriter0_queue) { +flexarray_append (dm_args,"-object" ); +flexarray_append (dm_args, +GCSPRINTF ("filter-rewriter,id=rs3,netdev=net%d,queue=%s" , + nics[i].devid, + nics[i].colo_filter_sec_rewriter0_queue)); + } }else {/* primary colo run */
tools/libxl/libxl_nic.c +27 -0
@@ -233,6 +233,20 @@ static void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,MAYBE_ADD_COLO_ARGS (compare_sec_in);MAYBE_ADD_COLO_ARGS (compare_out); +MAYBE_ADD_COLO_ARGS (sock_sec_redirector0_id); +MAYBE_ADD_COLO_ARGS (sock_sec_redirector0_ip); +MAYBE_ADD_COLO_ARGS (sock_sec_redirector0_port); +MAYBE_ADD_COLO_ARGS (sock_sec_redirector1_id); +MAYBE_ADD_COLO_ARGS (sock_sec_redirector1_ip); +MAYBE_ADD_COLO_ARGS (sock_sec_redirector1_port); +MAYBE_ADD_COLO_ARGS (filter_sec_redirector0_queue); +MAYBE_ADD_COLO_ARGS (filter_sec_redirector0_indev); +MAYBE_ADD_COLO_ARGS (filter_sec_redirector0_outdev); +MAYBE_ADD_COLO_ARGS (filter_sec_redirector1_queue); +MAYBE_ADD_COLO_ARGS (filter_sec_redirector1_indev); +MAYBE_ADD_COLO_ARGS (filter_sec_redirector1_outdev); +MAYBE_ADD_COLO_ARGS (filter_sec_rewriter0_queue); +#undef MAYBE_ADD_COLO_ARGSflexarray_append (back,"mac" );
@@ -424,6 +438,19 @@ static int libxl__device_nic_from_xenstore(libxl__gc *gc,CHECK_COLO_ARGS (compare_pri_in);CHECK_COLO_ARGS (compare_sec_in);CHECK_COLO_ARGS (compare_out); +CHECK_COLO_ARGS (sock_sec_redirector0_id); +CHECK_COLO_ARGS (sock_sec_redirector0_ip); +CHECK_COLO_ARGS (sock_sec_redirector0_port); +CHECK_COLO_ARGS (sock_sec_redirector1_id); +CHECK_COLO_ARGS (sock_sec_redirector1_ip); +CHECK_COLO_ARGS (sock_sec_redirector1_port); +CHECK_COLO_ARGS (filter_sec_redirector0_queue); +CHECK_COLO_ARGS (filter_sec_redirector0_indev); +CHECK_COLO_ARGS (filter_sec_redirector0_outdev); +CHECK_COLO_ARGS (filter_sec_redirector1_queue); +CHECK_COLO_ARGS (filter_sec_redirector1_indev); +CHECK_COLO_ARGS (filter_sec_redirector1_outdev); +CHECK_COLO_ARGS (filter_sec_rewriter0_queue);#undef CHECK_COLO_ARGS
tools/libxl/libxl_types.idl +14 -1
@@ -658,7 +658,20 @@ libxl_device_nic = Struct("device_nic", [ ("colo_filter_redirector1_outdev", string), ("colo_compare_pri_in", string), ("colo_compare_sec_in", string), - ("colo_compare_out", string) + ("colo_compare_out", string), + ("colo_sock_sec_redirector0_id", string), + ("colo_sock_sec_redirector0_ip", string), + ("colo_sock_sec_redirector0_port", string), + ("colo_sock_sec_redirector1_id", string), + ("colo_sock_sec_redirector1_ip", string), + ("colo_sock_sec_redirector1_port", string), + ("colo_filter_sec_redirector0_queue", string), + ("colo_filter_sec_redirector0_indev", string), + ("colo_filter_sec_redirector0_outdev", string), + ("colo_filter_sec_redirector1_queue", string), + ("colo_filter_sec_redirector1_indev", string), + ("colo_filter_sec_redirector1_outdev", string), + ("colo_filter_sec_rewriter0_queue", string) ]) libxl_device_pci = Struct("device_pci", [
tools/libxl/xl_cmdimpl.c +27 -0
@@ -1118,6 +1118,33 @@ static int parse_nic_config(libxl_device_nic *nic, XLU_Config **config, char *toreplace_string (&nic->colo_compare_sec_in, oparg); }else if (MATCH_OPTION ("colo_compare_out" , token, oparg)) {replace_string (&nic->colo_compare_out, oparg); + + }else if (MATCH_OPTION ("colo_sock_sec_redirector0_id" , token, oparg)) { +replace_string (&nic->colo_sock_sec_redirector0_id, oparg); + }else if (MATCH_OPTION ("colo_sock_sec_redirector0_ip" , token, oparg)) { +replace_string (&nic->colo_sock_sec_redirector0_ip, oparg); + }else if (MATCH_OPTION ("colo_sock_sec_redirector0_port" , token, oparg)) { +replace_string (&nic->colo_sock_sec_redirector0_port, oparg); + }else if (MATCH_OPTION ("colo_sock_sec_redirector1_id" , token, oparg)) { +replace_string (&nic->colo_sock_sec_redirector1_id, oparg); + }else if (MATCH_OPTION ("colo_sock_sec_redirector1_ip" , token, oparg)) { +replace_string (&nic->colo_sock_sec_redirector1_ip, oparg); + }else if (MATCH_OPTION ("colo_sock_sec_redirector1_port" , token, oparg)) { +replace_string (&nic->colo_sock_sec_redirector1_port, oparg); + }else if (MATCH_OPTION ("colo_filter_sec_redirector0_queue" , token, oparg)) { +replace_string (&nic->colo_filter_sec_redirector0_queue, oparg); + }else if (MATCH_OPTION ("colo_filter_sec_redirector0_indev" , token, oparg)) { +replace_string (&nic->colo_filter_sec_redirector0_indev, oparg); + }else if (MATCH_OPTION ("colo_filter_sec_redirector0_outdev" , token, oparg)) { +replace_string (&nic->colo_filter_sec_redirector0_outdev, oparg); + }else if (MATCH_OPTION ("colo_filter_sec_redirector1_queue" , token, oparg)) { +replace_string (&nic->colo_filter_sec_redirector1_queue, oparg); + }else if (MATCH_OPTION ("colo_filter_sec_redirector1_indev" , token, oparg)) { +replace_string (&nic->colo_filter_sec_redirector1_indev, oparg); + }else if (MATCH_OPTION ("colo_filter_sec_redirector1_outdev" , token, oparg)) { +replace_string (&nic->colo_filter_sec_redirector1_outdev, oparg); + }else if (MATCH_OPTION ("colo_filter_sec_rewriter0_queue" , token, oparg)) { +replace_string (&nic->colo_filter_sec_rewriter0_queue, oparg); }else if (MATCH_OPTION ("accel" , token, oparg)) {fprintf (stderr,"the accel parameter for vifs is currently not supported\n" ); }else {
Signature · 9 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 7/7 COLO-Proxy: Use socket to get checkpoint event.
In reply to Zhang ChenWe use kernel colo proxy's way to get the checkpoint event from qemu colo-compare.
Qemu colo-compare need add a API to support this(I will add this in qemu).
--- tools/libxl/libxl_colo.h | 2 + tools/libxl/libxl_colo_proxy.c | 85 +++++++++++++++++++++++++++++++++++++--- tools/libxl/libxl_colo_restore.c | 11 ++++-- tools/libxl/libxl_colo_save.c | 22 +++++++---- tools/libxl/libxl_nic.c | 4 ++ tools/libxl/libxl_types.idl | 4 +- tools/libxl/xl_cmdimpl.c | 4 ++ 7 files changed, 114 insertions(+), 18 deletions(-)
tools/libxl/libxl_colo.h +2 -0
@@ -69,6 +69,8 @@ struct libxl__colo_proxy_state {* False means use kernel colo proxy. */ bool is_userspace_proxy; +const char *checkpoint_host; +const char *checkpoint_port; };struct libxl__colo_save_state {
tools/libxl/libxl_colo_proxy.c +79 -6
126 lines not on this page · raw message
tools/libxl/libxl_colo_restore.c +7 -4
@@ -613,7 +613,8 @@ static void colo_restore_preresume_cb(libxl__egc *egc, } } -colo_proxy_preresume (&crs->cps); +if (!crs->cps.is_userspace_proxy) +colo_proxy_preresume (&crs->cps);colo_restore_resume_vm (egc, crcs);
@@ -786,9 +787,11 @@ static void colo_setup_checkpoint_devices(libxl__egc *egc, cds->ops = colo_restore_ops; crs->cps.ao = ao; -if (colo_proxy_setup (&crs->cps)) { -LOGD (ERROR , cds->domid,"COLO: failed to setup colo proxy for guest" ); - goto out; +if (!crs->cps.is_userspace_proxy) { +if (colo_proxy_setup (&crs->cps)) { +LOGD (ERROR , cds->domid,"COLO: failed to setup colo proxy for guest" ); + goto out; + } }if (init_device_subkind (cds))
tools/libxl/libxl_colo_save.c +15 -7
@@ -86,6 +86,7 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css)libxl__checkpoint_devices_state *const cds = &dss->cds;libxl__srm_save_autogen_callbacks *const callbacks = &dss->sws.shs.callbacks.save.a; +libxl_device_nic *nics;STATE_AO_GC (dss->ao);
@@ -110,24 +111,31 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) css->colo_proxy_script =GCSPRINTF ("%s/colo-proxy-setup" ,libxl__xen_script_dir_path ()); -/* If enable userspace proxy mode, we don't need VIF */ -if (css->cps.is_userspace_proxy) - cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VBD ); -else - cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VIF ) | - (1 <<LIBXL__DEVICE_KIND_VBD ); - cds->ops = colo_ops; cds->callback = colo_save_setup_done; cds->ao = ao; cds->domid = dss->domid; cds->concrete_data = css; +/* If enable userspace proxy mode, we don't need VIF */ +if (css->cps.is_userspace_proxy) { + cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VBD ); + +/* Use this args we can connect to qemu colo-compare */ + nics =libxl_device_nic_list (CTX , cds->domid, &cds->num_nics); + css->cps.checkpoint_host = nics->colo_checkpoint_host; + css->cps.checkpoint_port = nics->colo_checkpoint_port; + }else { + cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VIF ) | + (1 <<LIBXL__DEVICE_KIND_VBD ); + } + css->srs.ao = ao; css->srs.fd = css->recv_fd; css->srs.back_channel = true;libxl__stream_read_start (egc, &css->srs); css->cps.ao = ao; +if (colo_proxy_setup (&css->cps)) {LOGD (ERROR , cds->domid,"COLO: failed to setup colo proxy for guest" ); goto out;
tools/libxl/libxl_nic.c +4 -0
@@ -246,6 +246,8 @@ static void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,MAYBE_ADD_COLO_ARGS (filter_sec_redirector1_indev);MAYBE_ADD_COLO_ARGS (filter_sec_redirector1_outdev);MAYBE_ADD_COLO_ARGS (filter_sec_rewriter0_queue); +MAYBE_ADD_COLO_ARGS (checkpoint_host); +MAYBE_ADD_COLO_ARGS (checkpoint_port);#undef MAYBE_ADD_COLO_ARGS
@@ -451,6 +453,8 @@ static int libxl__device_nic_from_xenstore(libxl__gc *gc,CHECK_COLO_ARGS (filter_sec_redirector1_indev);CHECK_COLO_ARGS (filter_sec_redirector1_outdev);CHECK_COLO_ARGS (filter_sec_rewriter0_queue); +CHECK_COLO_ARGS (checkpoint_host); +CHECK_COLO_ARGS (checkpoint_port);#undef CHECK_COLO_ARGS
tools/libxl/libxl_types.idl +3 -1
@@ -671,7 +671,9 @@ libxl_device_nic = Struct("device_nic", [ ("colo_filter_sec_redirector1_queue", string), ("colo_filter_sec_redirector1_indev", string), ("colo_filter_sec_redirector1_outdev", string), - ("colo_filter_sec_rewriter0_queue", string) + ("colo_filter_sec_rewriter0_queue", string), + ("colo_checkpoint_host", string), + ("colo_checkpoint_port", string) ]) libxl_device_pci = Struct("device_pci", [
tools/libxl/xl_cmdimpl.c +4 -0
@@ -1145,6 +1145,10 @@ static int parse_nic_config(libxl_device_nic *nic, XLU_Config **config, char *toreplace_string (&nic->colo_filter_sec_redirector1_outdev, oparg); }else if (MATCH_OPTION ("colo_filter_sec_rewriter0_queue" , token, oparg)) {replace_string (&nic->colo_filter_sec_rewriter0_queue, oparg); + }else if (MATCH_OPTION ("colo_checkpoint_host" , token, oparg)) { +replace_string (&nic->colo_checkpoint_host, oparg); + }else if (MATCH_OPTION ("colo_checkpoint_port" , token, oparg)) { +replace_string (&nic->colo_checkpoint_port, oparg); }else if (MATCH_OPTION ("accel" , token, oparg)) {fprintf (stderr,"the accel parameter for vifs is currently not supported\n" ); }else {
Signature · 9 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH V3 7/7] COLO-Proxy: Use socket to get checkpoint event.
Quoted 53 lines · Zhang Chen
We use kernel colo proxy's way to get the checkpoint event from qemu colo-compare.
Qemu colo-compare need add a API to support this(I will add this in qemu).Signed-off-by Zhang Chen <[email protected]>--- tools/libxl/libxl_colo.h | 2 + tools/libxl/libxl_colo_proxy.c | 85 +++++++++++++++++++++++++++++++++++++--- tools/libxl/libxl_colo_restore.c | 11 ++++-- tools/libxl/libxl_colo_save.c | 22 +++++++---- tools/libxl/libxl_nic.c | 4 ++ tools/libxl/libxl_types.idl | 4 +- tools/libxl/xl_cmdimpl.c | 4 ++ 7 files changed, 114 insertions(+), 18 deletions(-)tools/libxl/libxl_colo.h +2
-0@@ -69,6 +69,8 @@ struct libxl__colo_proxy_state {* False means use kernel colo proxy. */ bool is_userspace_proxy; +const char *checkpoint_host; +const char *checkpoint_port; };struct libxl__colo_save_state {tools/libxl/libxl_colo_proxy.c +7
-0@@ -18,9 +18,13 @@#include "libxl_internal.h" #include <netlink/netlink.h> +#include <arpa/inet.h> +#include <sys/socket.h> +#include <netinet/in.h> /* Consistent with the new COLO netlink channel in kernel side */ #define NETLINK_COLO 28 +#define COLO_DEFAULT_WAIT_TIME 500000enum colo_netlink_op {COLO_QUERY_CHECKPOINT = (NLMSG_MIN_TYPE +1 ),@@ -76,6 +80,26 @@ static int colo_proxy_send(libxl__colo_proxy_state *cps, uint8_t *buff,return ret; } +static int colo_userspace_proxy_recv (libxl__colo_proxy_state *cps, +char *buff, +unsigned int timeout_us)
tools/libxl/libxl_colo_proxy.c static int colo_proxy_send(libxl__colo_proxy_state *cps, uint8_t *buff, · line 95
Quoted 10 lines
tools/libxl/libxl_colo_proxy.c +10
-0+{ +struct timeval tv; +int ret; + +STATE_AO_GC (cps->ao); + +if (timeout_us) { + tv.tv_sec = timeout_us /1000000 ; + tv.tv_usec = timeout_us %1000000 ; +setsockopt (cps->sock_fd,SOL_SOCKET ,SO_RCVTIMEO , &tv,sizeof (tv));
Please check the return value of setsockopt and handle error appropriately. If you don't care about the error, please add a comment.
Quoted 58 lines
tools/libxl/libxl_colo_proxy.c +45
-1+ } + + ret =recv (cps->sock_fd, buff,sizeof (buff),0 ); + +return ret; +} +/* error: return -1, otherwise return 0 */ static int64_t colo_proxy_recv (libxl__colo_proxy_state *cps,uint8_t **buff,unsigned int timeout_us)@@ -153,8 +177,45 @@ int colo_proxy_setup(libxl__colo_proxy_state *cps)STATE_AO_GC (cps->ao);/* If enable userspace proxy mode, we don't need setup kernel proxy */ -if (cps->is_userspace_proxy) +if (cps->is_userspace_proxy) { +struct sockaddr_in addr; +int port; +char recvbuff[1024 ]; +char sendbuf[] ="COLO_USERSPACE_PROXY_INIT" ; + +memset (&addr,0 ,sizeof (addr)); + port =atoi (cps->checkpoint_port); + addr.sin_family =AF_INET ; + addr.sin_port =htons (port); + addr.sin_addr.s_addr =inet_addr (cps->checkpoint_host); + + skfd =socket (AF_INET ,SOCK_STREAM ,0 ); +if (skfd <0 ) { +LOGD (ERROR , ao->domid,"can not create a TCP socket: %s" , +strerror (errno)); + goto out; + } + + cps->sock_fd = skfd; + +if (connect (skfd, (struct sockaddr *)&addr,sizeof (addr)) <0 ) { +LOGD (ERROR , ao->domid,"connect error" ); + goto out; + } + + ret =send (skfd, sendbuf,strlen (sendbuf),0 ); +if (ret <0 ) + goto out; + + ret =colo_userspace_proxy_recv (cps, recvbuff,COLO_DEFAULT_WAIT_TIME ); +if (ret <0 ) { +LOGD (ERROR , ao->domid,"Can't recv msg from qemu colo-compare: %s" , +strerror (errno)); + goto out; + } +return 0 ; + } skfd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_COLO );if (skfd <0 ) {
tools/libxl/libxl_colo_proxy.c void colo_proxy_preresume(libxl__colo_proxy_state *cps) · line 312
Quoted 6 lines
tools/libxl/libxl_colo_proxy.c +2
-1@@ -247,8 +308,11 @@ void colo_proxy_preresume(libxl__colo_proxy_state *cps)* If enable userspace proxy mode, * we don't need preresume kernel proxy */ -if (cps->is_userspace_proxy) +if (cps->is_userspace_proxy) { +char sendbuf[] ="COLO_CHECKPOINT" ;
Please constify it.
tools/libxl/libxl_colo_proxy.c void colo_proxy_preresume(libxl__colo_proxy_state *cps) · line 313
Quoted 1 line
tools/libxl/libxl_colo_proxy.c +1
-0+send (cps->sock_fd, sendbuf,strlen (sendbuf),0 );
Space before "0".
Quoted 21 lines
tools/libxl/libxl_colo_proxy.c +4
-3return ; + }colo_proxy_send (cps,NULL ,0 ,COLO_CHECKPOINT );/* TODO: need to handle if the call fails... */ @@ -277,16 +341,25 @@ int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,struct nlmsghdr *h;struct colo_msg *m;int ret =-1 ; +char recvbuff[1024 ];STATE_AO_GC (cps->ao);/* -* enable userspace proxy mode, tmp sleep. -* then we will add qemu API support this func. +* enable userspace proxy mode. +* Then we will add qemu API support for this func. */ if (cps->is_userspace_proxy) { -sleep (timeout_us /1000000 );
tools/libxl/libxl_colo_proxy.c int colo_proxy_checkpoint(libxl__colo_proxy_state *cps, · line 361
Quoted 10 lines
tools/libxl/libxl_colo_proxy.c +9
-1-return 0 ; + ret =colo_userspace_proxy_recv (cps, recvbuff, timeout_us); +if (ret <=0 ) +return 0 ; + +if (!strcmp (recvbuff,"DO_CHECKPOINT" )) { +return 1 ; + }else { +LOGD (ERROR , ao->domid,"receive qemu colo-compare checkpoint error" ); +return -1 ;
Please use goto style error handling if possible. Please refer to CODING_STYLE file inside libxl directory.
Quoted 71 lines
tools/libxl/libxl_colo_proxy.c +1
-0+ } } size =colo_proxy_recv (cps, &buff, timeout_us);tools/libxl/libxl_colo_restore.c +7
-4@@ -613,7 +613,8 @@ static void colo_restore_preresume_cb(libxl__egc *egc, } } -colo_proxy_preresume (&crs->cps); +if (!crs->cps.is_userspace_proxy) +colo_proxy_preresume (&crs->cps);colo_restore_resume_vm (egc, crcs);@@ -786,9 +787,11 @@ static void colo_setup_checkpoint_devices(libxl__egc *egc, cds->ops = colo_restore_ops; crs->cps.ao = ao; -if (colo_proxy_setup (&crs->cps)) { -LOGD (ERROR , cds->domid,"COLO: failed to setup colo proxy for guest" ); - goto out; +if (!crs->cps.is_userspace_proxy) { +if (colo_proxy_setup (&crs->cps)) { +LOGD (ERROR , cds->domid,"COLO: failed to setup colo proxy for guest" ); + goto out; + } }if (init_device_subkind (cds))tools/libxl/libxl_colo_save.c +10
-7@@ -86,6 +86,7 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css)libxl__checkpoint_devices_state *const cds = &dss->cds;libxl__srm_save_autogen_callbacks *const callbacks = &dss->sws.shs.callbacks.save.a; +libxl_device_nic *nics;STATE_AO_GC (dss->ao);@@ -110,24 +111,31 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) css->colo_proxy_script =GCSPRINTF ("%s/colo-proxy-setup" ,libxl__xen_script_dir_path ()); -/* If enable userspace proxy mode, we don't need VIF */ -if (css->cps.is_userspace_proxy) - cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VBD ); -else - cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VIF ) | - (1 <<LIBXL__DEVICE_KIND_VBD ); - cds->ops = colo_ops; cds->callback = colo_save_setup_done; cds->ao = ao; cds->domid = dss->domid; cds->concrete_data = css; +/* If enable userspace proxy mode, we don't need VIF */ +if (css->cps.is_userspace_proxy) { + cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VBD ); + +/* Use this args we can connect to qemu colo-compare */ + nics =libxl_device_nic_list (CTX , cds->domid, &cds->num_nics); + css->cps.checkpoint_host = nics->colo_checkpoint_host; + css->cps.checkpoint_port = nics->colo_checkpoint_port; + }else {
tools/libxl/libxl_colo_save.c void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) · line 138
Quoted 10 lines
tools/libxl/libxl_colo_save.c +5
-0+ cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VIF ) | + (1 <<LIBXL__DEVICE_KIND_VBD ); + } + css->srs.ao = ao; css->srs.fd = css->recv_fd; css->srs.back_channel = true;libxl__stream_read_start (egc, &css->srs); css->cps.ao = ao; +
Stray blank line.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH V3 7/7] COLO-Proxy: Use socket to get checkpoint event.
Quoted 51 lines · Wei Liu
Quoted 50 lines · Zhang Chen
We use kernel colo proxy's way to get the checkpoint event from qemu colo-compare.
Qemu colo-compare need add a API to support this(I will add this in qemu).Signed-off-by Zhang Chen <[email protected]>--- tools/libxl/libxl_colo.h | 2 + tools/libxl/libxl_colo_proxy.c | 85 +++++++++++++++++++++++++++++++++++++--- tools/libxl/libxl_colo_restore.c | 11 ++++-- tools/libxl/libxl_colo_save.c | 22 +++++++---- tools/libxl/libxl_nic.c | 4 ++ tools/libxl/libxl_types.idl | 4 +- tools/libxl/xl_cmdimpl.c | 4 ++ 7 files changed, 114 insertions(+), 18 deletions(-)tools/libxl/libxl_colo.h +2
-0@@ -69,6 +69,8 @@ struct libxl__colo_proxy_state {* False means use kernel colo proxy. */ bool is_userspace_proxy; +const char *checkpoint_host; +const char *checkpoint_port; };struct libxl__colo_save_state {tools/libxl/libxl_colo_proxy.c +4
-0@@ -18,9 +18,13 @@#include "libxl_internal.h" #include <netlink/netlink.h> +#include <arpa/inet.h> +#include <sys/socket.h> +#include <netinet/in.h> /* Consistent with the new COLO netlink channel in kernel side */ #define NETLINK_COLO 28 +#define COLO_DEFAULT_WAIT_TIME 500000enum colo_netlink_op {COLO_QUERY_CHECKPOINT = (NLMSG_MIN_TYPE +1 ),@@ -76,6 +80,26 @@ static int colo_proxy_send(libxl__colo_proxy_state *cps, uint8_t *buff,return ret; }
Quoted 15 lines
tools/libxl/libxl_colo_proxy.c static int colo_proxy_send(libxl__colo_proxy_state *cps, uint8_t *buff, · line 95
Quoted 13 lines
tools/libxl/libxl_colo_proxy.c +13
-0+static int colo_userspace_proxy_recv (libxl__colo_proxy_state *cps, +char *buff, +unsigned int timeout_us) +{ +struct timeval tv; +int ret; + +STATE_AO_GC (cps->ao); + +if (timeout_us) { + tv.tv_sec = timeout_us /1000000 ; + tv.tv_usec = timeout_us %1000000 ; +setsockopt (cps->sock_fd,SOL_SOCKET ,SO_RCVTIMEO , &tv,sizeof (tv));Please check the return value of setsockopt and handle error appropriately. If you don't care about the error, please add a comment.
OK.
Quoted 56 lines
Quoted 56 lines
tools/libxl/libxl_colo_proxy.c +45
-1+ } + + ret =recv (cps->sock_fd, buff,sizeof (buff),0 ); + +return ret; +} +/* error: return -1, otherwise return 0 */ static int64_t colo_proxy_recv (libxl__colo_proxy_state *cps,uint8_t **buff,unsigned int timeout_us)@@ -153,8 +177,45 @@ int colo_proxy_setup(libxl__colo_proxy_state *cps)STATE_AO_GC (cps->ao);/* If enable userspace proxy mode, we don't need setup kernel proxy */ -if (cps->is_userspace_proxy) +if (cps->is_userspace_proxy) { +struct sockaddr_in addr; +int port; +char recvbuff[1024 ]; +char sendbuf[] ="COLO_USERSPACE_PROXY_INIT" ; + +memset (&addr,0 ,sizeof (addr)); + port =atoi (cps->checkpoint_port); + addr.sin_family =AF_INET ; + addr.sin_port =htons (port); + addr.sin_addr.s_addr =inet_addr (cps->checkpoint_host); + + skfd =socket (AF_INET ,SOCK_STREAM ,0 ); +if (skfd <0 ) { +LOGD (ERROR , ao->domid,"can not create a TCP socket: %s" , +strerror (errno)); + goto out; + } + + cps->sock_fd = skfd; + +if (connect (skfd, (struct sockaddr *)&addr,sizeof (addr)) <0 ) { +LOGD (ERROR , ao->domid,"connect error" ); + goto out; + } + + ret =send (skfd, sendbuf,strlen (sendbuf),0 ); +if (ret <0 ) + goto out; + + ret =colo_userspace_proxy_recv (cps, recvbuff,COLO_DEFAULT_WAIT_TIME ); +if (ret <0 ) { +LOGD (ERROR , ao->domid,"Can't recv msg from qemu colo-compare: %s" , +strerror (errno)); + goto out; + } +return 0 ; + }
Quoted 10 lines
tools/libxl/libxl_colo_proxy.c void colo_proxy_preresume(libxl__colo_proxy_state *cps) · line 312
Quoted 9 lines
tools/libxl/libxl_colo_proxy.c +2
-1skfd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_COLO );if (skfd <0 ) {@@ -247,8 +308,11 @@ void colo_proxy_preresume(libxl__colo_proxy_state *cps)* If enable userspace proxy mode, * we don't need preresume kernel proxy */ -if (cps->is_userspace_proxy) +if (cps->is_userspace_proxy) { +char sendbuf[] ="COLO_CHECKPOINT" ;Please constify it.
OK~~
Quoted 3 lines
tools/libxl/libxl_colo_proxy.c void colo_proxy_preresume(libxl__colo_proxy_state *cps) · line 313
Quoted 2 lines
tools/libxl/libxl_colo_proxy.c +1
-0+send (cps->sock_fd, sendbuf,strlen (sendbuf),0 );Space before "0".
Good catch.
Quoted 26 lines
Quoted 26 lines
tools/libxl/libxl_colo_proxy.c +7
-4return ; + }colo_proxy_send (cps,NULL ,0 ,COLO_CHECKPOINT );/* TODO: need to handle if the call fails... */ @@ -277,16 +341,25 @@ int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,struct nlmsghdr *h;struct colo_msg *m;int ret =-1 ; +char recvbuff[1024 ];STATE_AO_GC (cps->ao);/* -* enable userspace proxy mode, tmp sleep. -* then we will add qemu API support this func. +* enable userspace proxy mode. +* Then we will add qemu API support for this func. */ if (cps->is_userspace_proxy) { -sleep (timeout_us /1000000 ); -return 0 ; + ret =colo_userspace_proxy_recv (cps, recvbuff, timeout_us); +if (ret <=0 ) +return 0 ;
Quoted 8 lines
tools/libxl/libxl_colo_proxy.c int colo_proxy_checkpoint(libxl__colo_proxy_state *cps, · line 361
Quoted 6 lines
tools/libxl/libxl_colo_proxy.c +6
-0+ +if (!strcmp (recvbuff,"DO_CHECKPOINT" )) { +return 1 ; + }else { +LOGD (ERROR , ao->domid,"receive qemu colo-compare checkpoint error" ); +return -1 ;Please use goto style error handling if possible. Please refer to
CODING_STYLEfile inside libxl directory.
I will fix it in next version.
Quoted 75 lines
Quoted 75 lines
tools/libxl/libxl_colo_proxy.c +1
-0+ } } size =colo_proxy_recv (cps, &buff, timeout_us);tools/libxl/libxl_colo_restore.c +7
-4@@ -613,7 +613,8 @@ static void colo_restore_preresume_cb(libxl__egc *egc, } } -colo_proxy_preresume (&crs->cps); +if (!crs->cps.is_userspace_proxy) +colo_proxy_preresume (&crs->cps);colo_restore_resume_vm (egc, crcs);@@ -786,9 +787,11 @@ static void colo_setup_checkpoint_devices(libxl__egc *egc, cds->ops = colo_restore_ops; crs->cps.ao = ao; -if (colo_proxy_setup (&crs->cps)) { -LOGD (ERROR , cds->domid,"COLO: failed to setup colo proxy for guest" ); - goto out; +if (!crs->cps.is_userspace_proxy) { +if (colo_proxy_setup (&crs->cps)) { +LOGD (ERROR , cds->domid,"COLO: failed to setup colo proxy for guest" ); + goto out; + } }if (init_device_subkind (cds))tools/libxl/libxl_colo_save.c +13
-7@@ -86,6 +86,7 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css)libxl__checkpoint_devices_state *const cds = &dss->cds;libxl__srm_save_autogen_callbacks *const callbacks = &dss->sws.shs.callbacks.save.a; +libxl_device_nic *nics;STATE_AO_GC (dss->ao);@@ -110,24 +111,31 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) css->colo_proxy_script =GCSPRINTF ("%s/colo-proxy-setup" ,libxl__xen_script_dir_path ()); -/* If enable userspace proxy mode, we don't need VIF */ -if (css->cps.is_userspace_proxy) - cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VBD ); -else - cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VIF ) | - (1 <<LIBXL__DEVICE_KIND_VBD ); - cds->ops = colo_ops; cds->callback = colo_save_setup_done; cds->ao = ao; cds->domid = dss->domid; cds->concrete_data = css; +/* If enable userspace proxy mode, we don't need VIF */ +if (css->cps.is_userspace_proxy) { + cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VBD ); + +/* Use this args we can connect to qemu colo-compare */ + nics =libxl_device_nic_list (CTX , cds->domid, &cds->num_nics); + css->cps.checkpoint_host = nics->colo_checkpoint_host; + css->cps.checkpoint_port = nics->colo_checkpoint_port; + }else { + cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VIF ) | + (1 <<LIBXL__DEVICE_KIND_VBD ); + }
Quoted 8 lines
tools/libxl/libxl_colo_save.c void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) · line 138
Quoted 7 lines
tools/libxl/libxl_colo_save.c +2
-0+ css->srs.ao = ao; css->srs.fd = css->recv_fd; css->srs.back_channel = true;libxl__stream_read_start (egc, &css->srs); css->cps.ao = ao; +Stray blank line.
I Will Remove it in next version.
Thanks
Zhang Chen
Quoted 6 lines
Wei.
.
Signature · 10 lines
Thanks Zhang Chen _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel