diff mbox

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

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

Commit Message

Zhang Chen Feb. 17, 2017, 2:18 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 | 27 +++++++++++++++++++++++++++
 tools/libxl/libxl_colo_save.c  |  9 +++++++--
 2 files changed, 34 insertions(+), 2 deletions(-)

Comments

Wei Liu Feb. 20, 2017, 3:55 p.m. UTC | #1
On Fri, Feb 17, 2017 at 10:18:24AM +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>
> ---
>  tools/libxl/libxl_colo_proxy.c | 27 +++++++++++++++++++++++++++
>  tools/libxl/libxl_colo_save.c  |  9 +++++++--
>  2 files changed, 34 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/libxl/libxl_colo_proxy.c b/tools/libxl/libxl_colo_proxy.c
> index 0983f42..dd902fc 100644
> --- a/tools/libxl/libxl_colo_proxy.c
> +++ b/tools/libxl/libxl_colo_proxy.c
> @@ -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);

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.
Zhang Chen Feb. 21, 2017, 2:57 a.m. UTC | #2
On 02/20/2017 11:55 PM, Wei Liu wrote:
> On Fri, Feb 17, 2017 at 10:18:24AM +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>
>> ---
>>   tools/libxl/libxl_colo_proxy.c | 27 +++++++++++++++++++++++++++
>>   tools/libxl/libxl_colo_save.c  |  9 +++++++--
>>   2 files changed, 34 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/libxl/libxl_colo_proxy.c b/tools/libxl/libxl_colo_proxy.c
>> index 0983f42..dd902fc 100644
>> --- a/tools/libxl/libxl_colo_proxy.c
>> +++ b/tools/libxl/libxl_colo_proxy.c
>> @@ -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);
> usleep is better.

OK.

>
> 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

>
> Wei.
>
>
> .
>
Wei Liu Feb. 21, 2017, 9:53 a.m. UTC | #3
On Tue, Feb 21, 2017 at 10:57:46AM +0800, Zhang Chen wrote:
> 
> 
> On 02/20/2017 11:55 PM, Wei Liu wrote:
> > On Fri, Feb 17, 2017 at 10:18:24AM +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>
> > > ---
> > >   tools/libxl/libxl_colo_proxy.c | 27 +++++++++++++++++++++++++++
> > >   tools/libxl/libxl_colo_save.c  |  9 +++++++--
> > >   2 files changed, 34 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/tools/libxl/libxl_colo_proxy.c b/tools/libxl/libxl_colo_proxy.c
> > > index 0983f42..dd902fc 100644
> > > --- a/tools/libxl/libxl_colo_proxy.c
> > > +++ b/tools/libxl/libxl_colo_proxy.c
> > > @@ -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);
> > usleep is better.
> 
> OK.
> 
> > 
> > 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?

> Thanks
> Zhang Chen
> 
> > 
> > Wei.
> > 
> > 
> > .
> > 
> 
> -- 
> Thanks
> Zhang Chen
> 
> 
>
Zhang Chen Feb. 21, 2017, 11:03 a.m. UTC | #4
On 02/21/2017 05:53 PM, Wei Liu wrote:
> On Tue, Feb 21, 2017 at 10:57:46AM +0800, Zhang Chen wrote:
>>
>> On 02/20/2017 11:55 PM, Wei Liu wrote:
>>> On Fri, Feb 17, 2017 at 10:18:24AM +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>
>>>> ---
>>>>    tools/libxl/libxl_colo_proxy.c | 27 +++++++++++++++++++++++++++
>>>>    tools/libxl/libxl_colo_save.c  |  9 +++++++--
>>>>    2 files changed, 34 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/tools/libxl/libxl_colo_proxy.c b/tools/libxl/libxl_colo_proxy.c
>>>> index 0983f42..dd902fc 100644
>>>> --- a/tools/libxl/libxl_colo_proxy.c
>>>> +++ b/tools/libxl/libxl_colo_proxy.c
>>>> @@ -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);
>>> usleep is better.
>> OK.
>>
>>> 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?

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

>
>> Thanks
>> Zhang Chen
>>
>>> Wei.
>>>
>>>
>>> .
>>>
>> -- 
>> Thanks
>> Zhang Chen
>>
>>
>>
>
> .
>
Wei Liu Feb. 21, 2017, 11:18 a.m. UTC | #5
On Tue, Feb 21, 2017 at 07:03:29PM +0800, Zhang Chen wrote:
> 
> 
> On 02/21/2017 05:53 PM, Wei Liu wrote:
> > On Tue, Feb 21, 2017 at 10:57:46AM +0800, Zhang Chen wrote:
> > > 
> > > On 02/20/2017 11:55 PM, Wei Liu wrote:
> > > > On Fri, Feb 17, 2017 at 10:18:24AM +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>
> > > > > ---
> > > > >    tools/libxl/libxl_colo_proxy.c | 27 +++++++++++++++++++++++++++
> > > > >    tools/libxl/libxl_colo_save.c  |  9 +++++++--
> > > > >    2 files changed, 34 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/tools/libxl/libxl_colo_proxy.c b/tools/libxl/libxl_colo_proxy.c
> > > > > index 0983f42..dd902fc 100644
> > > > > --- a/tools/libxl/libxl_colo_proxy.c
> > > > > +++ b/tools/libxl/libxl_colo_proxy.c
> > > > > @@ -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);
> > > > usleep is better.
> > > OK.
> > > 
> > > > 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?
> 
> 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.

> 
> Thanks
> Zhang Chen
> 
> > 
> > > Thanks
> > > Zhang Chen
> > > 
> > > > Wei.
> > > > 
> > > > 
> > > > .
> > > > 
> > > -- 
> > > Thanks
> > > Zhang Chen
> > > 
> > > 
> > > 
> > 
> > .
> > 
> 
> -- 
> Thanks
> Zhang Chen
> 
> 
>
Zhang Chen Feb. 21, 2017, 1:12 p.m. UTC | #6
On 02/21/2017 07:18 PM, Wei Liu wrote:
> On Tue, Feb 21, 2017 at 07:03:29PM +0800, Zhang Chen wrote:
>>
>> On 02/21/2017 05:53 PM, Wei Liu wrote:
>>> On Tue, Feb 21, 2017 at 10:57:46AM +0800, Zhang Chen wrote:
>>>> On 02/20/2017 11:55 PM, Wei Liu wrote:
>>>>> On Fri, Feb 17, 2017 at 10:18:24AM +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>
>>>>>> ---
>>>>>>     tools/libxl/libxl_colo_proxy.c | 27 +++++++++++++++++++++++++++
>>>>>>     tools/libxl/libxl_colo_save.c  |  9 +++++++--
>>>>>>     2 files changed, 34 insertions(+), 2 deletions(-)
>>>>>>
>>>>>> diff --git a/tools/libxl/libxl_colo_proxy.c b/tools/libxl/libxl_colo_proxy.c
>>>>>> index 0983f42..dd902fc 100644
>>>>>> --- a/tools/libxl/libxl_colo_proxy.c
>>>>>> +++ b/tools/libxl/libxl_colo_proxy.c
>>>>>> @@ -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);
>>>>> usleep is better.
>>>> OK.
>>>>
>>>>> 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?
>> 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.

Make sense. I will add more comments in next version.

Thanks
Zhang Chen

>
> Wei.
>
>> Thanks
>> Zhang Chen
>>
>>>> Thanks
>>>> Zhang Chen
>>>>
>>>>> Wei.
>>>>>
>>>>>
>>>>> .
>>>>>
>>>> -- 
>>>> Thanks
>>>> Zhang Chen
>>>>
>>>>
>>>>
>>> .
>>>
>> -- 
>> Thanks
>> Zhang Chen
>>
>>
>>
>
> .
>
diff mbox

Patch

diff --git a/tools/libxl/libxl_colo_proxy.c b/tools/libxl/libxl_colo_proxy.c
index 0983f42..dd902fc 100644
--- a/tools/libxl/libxl_colo_proxy.c
+++ b/tools/libxl/libxl_colo_proxy.c
@@ -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. */
diff --git a/tools/libxl/libxl_colo_save.c b/tools/libxl/libxl_colo_save.c
index eb8336c..91e3fce 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;