diff mbox

[RFC,2/6] COLO-Proxy: Setup userspace colo-proxy on primary side

Message ID 1485412569-7431-3-git-send-email-zhangchen.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zhang Chen Jan. 26, 2017, 6:36 a.m. UTC
In this patch we close kernel COLO-Proxy on primary side.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
---
 tools/libxl/libxl_colo_proxy.c | 30 ++++++++++++++++++++++++++++++
 tools/libxl/libxl_colo_save.c  |  9 +++++++--
 2 files changed, 37 insertions(+), 2 deletions(-)

Comments

Wei Liu Jan. 27, 2017, 5:05 p.m. UTC | #1
On Thu, Jan 26, 2017 at 02:36:05PM +0800, Zhang Chen wrote:
> In this patch we close kernel COLO-Proxy on primary side.
> 
> Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

I don't claim I know much about COLO though, nor have I ever run it, so
it would be better to have a second eye on this patch.

There are some style nits below.

> ---
>  tools/libxl/libxl_colo_proxy.c | 30 ++++++++++++++++++++++++++++++
>  tools/libxl/libxl_colo_save.c  |  9 +++++++--
>  2 files changed, 37 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/libxl/libxl_colo_proxy.c b/tools/libxl/libxl_colo_proxy.c
> index 0983f42..348484d 100644
> --- a/tools/libxl/libxl_colo_proxy.c
> +++ b/tools/libxl/libxl_colo_proxy.c
> @@ -152,6 +152,11 @@ int colo_proxy_setup(libxl__colo_proxy_state *cps)
>  
>      STATE_AO_GC(cps->ao);
>  
> +    if (cps->is_userspace_proxy) {
> +        /* If enable userspace proxy mode, we don't need setup kernel proxy */
> +        return 0;
> +    }
> +

There is only one statement so no need to have {}.

You can move the comment before "if" and remove {}.

Same rule applies to all the patches.

Wei.
Zhang Chen Feb. 6, 2017, 6:32 a.m. UTC | #2
On 01/28/2017 01:05 AM, Wei Liu wrote:
> On Thu, Jan 26, 2017 at 02:36:05PM +0800, Zhang Chen wrote:
>> In this patch we close kernel COLO-Proxy on primary side.
>>
>> Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
> Acked-by: Wei Liu <wei.liu2@citrix.com>
>
> I don't claim I know much about COLO though, nor have I ever run it, so
> it would be better to have a second eye on this patch.
>
> There are some style nits below.
>
>> ---
>>   tools/libxl/libxl_colo_proxy.c | 30 ++++++++++++++++++++++++++++++
>>   tools/libxl/libxl_colo_save.c  |  9 +++++++--
>>   2 files changed, 37 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/libxl/libxl_colo_proxy.c b/tools/libxl/libxl_colo_proxy.c
>> index 0983f42..348484d 100644
>> --- a/tools/libxl/libxl_colo_proxy.c
>> +++ b/tools/libxl/libxl_colo_proxy.c
>> @@ -152,6 +152,11 @@ int colo_proxy_setup(libxl__colo_proxy_state *cps)
>>   
>>       STATE_AO_GC(cps->ao);
>>   
>> +    if (cps->is_userspace_proxy) {
>> +        /* If enable userspace proxy mode, we don't need setup kernel proxy */
>> +        return 0;
>> +    }
>> +
> There is only one statement so no need to have {}.
>
> You can move the comment before "if" and remove {}.
>
> Same rule applies to all the patches.

OK, I will fix this in next version.

Thanks
Zhang Chen

>
> Wei.
>
>
> .
>
diff mbox

Patch

diff --git a/tools/libxl/libxl_colo_proxy.c b/tools/libxl/libxl_colo_proxy.c
index 0983f42..348484d 100644
--- a/tools/libxl/libxl_colo_proxy.c
+++ b/tools/libxl/libxl_colo_proxy.c
@@ -152,6 +152,11 @@  int colo_proxy_setup(libxl__colo_proxy_state *cps)
 
     STATE_AO_GC(cps->ao);
 
+    if (cps->is_userspace_proxy) {
+        /* If enable userspace proxy mode, we don't need setup kernel 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 +227,14 @@  out:
 
 void colo_proxy_teardown(libxl__colo_proxy_state *cps)
 {
+    if (cps->is_userspace_proxy) {
+        /*
+         * If enable userspace proxy mode,
+         * we don't need teardown kernel proxy
+         */
+        return;
+    }
+
     if (cps->sock_fd >= 0) {
         close(cps->sock_fd);
         cps->sock_fd = -1;
@@ -232,6 +245,14 @@  void colo_proxy_teardown(libxl__colo_proxy_state *cps)
 
 void colo_proxy_preresume(libxl__colo_proxy_state *cps)
 {
+    if (cps->is_userspace_proxy) {
+        /*
+         * If enable userspace proxy mode,
+         * we don't need preresume kernel proxy
+         */
+        return;
+    }
+
     colo_proxy_send(cps, NULL, 0, COLO_CHECKPOINT);
     /* TODO: need to handle if the call fails... */
 }
@@ -260,6 +281,15 @@  int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,
     struct colo_msg *m;
     int ret = -1;
 
+    /*
+     * 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;
+    }
+
     STATE_AO_GC(cps->ao);
 
     size = colo_proxy_recv(cps, &buff, timeout_us);
diff --git a/tools/libxl/libxl_colo_save.c b/tools/libxl/libxl_colo_save.c
index eb8336c..7b6e38f 100644
--- a/tools/libxl/libxl_colo_save.c
+++ b/tools/libxl/libxl_colo_save.c
@@ -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;