From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXgqe-0002u4-4J for qemu-devel@nongnu.org; Sun, 21 Feb 2016 22:07:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXgqa-0005O8-3U for qemu-devel@nongnu.org; Sun, 21 Feb 2016 22:07:44 -0500 Received: from [59.151.112.132] (port=8786 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXgqX-0005NW-TG for qemu-devel@nongnu.org; Sun, 21 Feb 2016 22:07:40 -0500 References: <1450780978-19123-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> <1450780978-19123-6-git-send-email-zhangchen.fnst@cn.fujitsu.com> <20160219195849.GJ2412@work-vm> From: Zhang Chen Message-ID: <56CA7B96.2090603@cn.fujitsu.com> Date: Mon, 22 Feb 2016 11:08:06 +0800 MIME-Version: 1.0 In-Reply-To: <20160219195849.GJ2412@work-vm> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH v2 05/10] net/colo-proxy: Add colo interface to use proxy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: zhanghailiang , Li Zhijian , Gui jianfeng , Jason Wang , "eddie.dong" , qemu devel , Huang peng , Gong lei , Stefan Hajnoczi , jan.kiszka@siemens.com, Yang Hongyang On 02/20/2016 03:58 AM, Dr. David Alan Gilbert wrote: > * Zhang Chen (zhangchen.fnst@cn.fujitsu.com) wrote: >> From: zhangchen >> >> Add interface used by migration/colo.c >> so colo framework can work with proxy >> >> Signed-off-by: zhangchen >> Signed-off-by: zhanghailiang >> --- >> net/colo-proxy.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 93 insertions(+) >> >> diff --git a/net/colo-proxy.c b/net/colo-proxy.c >> index f448ee1..ba2bbe7 100644 >> --- a/net/colo-proxy.c >> +++ b/net/colo-proxy.c >> @@ -167,6 +167,11 @@ static int connection_key_equal(const void *opaque1, const void *opaque2) >> return memcmp(opaque1, opaque2, sizeof(ConnectionKey)) == 0; >> } >> >> +bool colo_proxy_query_checkpoint(void) >> +{ >> + return colo_do_checkpoint; >> +} >> + >> static ssize_t colo_proxy_receive_iov(NetFilterState *nf, >> NetClientState *sender, >> unsigned flags, >> @@ -203,6 +208,94 @@ static void colo_proxy_cleanup(NetFilterState *nf) >> qemu_event_destroy(&s->need_compare_ev); >> } >> >> +static void colo_proxy_notify_checkpoint(void) >> +{ >> + trace_colo_proxy("colo_proxy_notify_checkpoint"); >> + colo_do_checkpoint = true; >> +} >> + >> +static void colo_proxy_start_one(NetFilterState *nf, >> + void *opaque, Error **errp) >> +{ >> + COLOProxyState *s; >> + int mode, ret; >> + >> + if (strcmp(object_get_typename(OBJECT(nf)), TYPE_FILTER_COLO_PROXY)) { >> + return; >> + } >> + >> + mode = *(int *)opaque; >> + s = FILTER_COLO_PROXY(nf); >> + assert(s->colo_mode == mode); >> + >> + if (s->colo_mode == COLO_MODE_PRIMARY) { >> + char thread_name[1024]; >> + >> + ret = colo_proxy_connect(s); >> + if (ret) { >> + error_setg(errp, "colo proxy connect failed"); >> + return ; >> + } >> + >> + s->status = COLO_PROXY_RUNNING; >> + sprintf(thread_name, "proxy compare %s", nf->netdev_id); >> + qemu_thread_create(&s->thread, thread_name, >> + colo_proxy_compare_thread, s, >> + QEMU_THREAD_JOINABLE); > Note most OSs have a ~14 character limit on the size of the thread > name, otherwise they ignore the request to set the name (and the > thread shows up as 'migration'), so I suggest keep it as "proxy:%s". > > Dave I will fix it in colo-compare module. Thanks zhangchen >> + } else { >> + ret = colo_wait_incoming(s); >> + if (ret) { >> + error_setg(errp, "colo proxy wait incoming failed"); >> + return ; >> + } >> + s->status = COLO_PROXY_RUNNING; >> + } >> +} >> + >> +int colo_proxy_start(int mode) >> +{ >> + Error *err = NULL; >> + qemu_foreach_netfilter(colo_proxy_start_one, &mode, &err); >> + if (err) { >> + return -1; >> + } >> + return 0; >> +} >> + >> +static void colo_proxy_stop_one(NetFilterState *nf, >> + void *opaque, Error **errp) >> +{ >> + COLOProxyState *s; >> + int mode; >> + >> + if (strcmp(object_get_typename(OBJECT(nf)), TYPE_FILTER_COLO_PROXY)) { >> + return; >> + } >> + >> + s = FILTER_COLO_PROXY(nf); >> + mode = *(int *)opaque; >> + assert(s->colo_mode == mode); >> + >> + s->status = COLO_PROXY_DONE; >> + if (s->sockfd >= 0) { >> + qemu_set_fd_handler(s->sockfd, NULL, NULL, NULL); >> + closesocket(s->sockfd); >> + } >> + if (s->colo_mode == COLO_MODE_PRIMARY) { >> + colo_proxy_primary_checkpoint(s); >> + qemu_event_set(&s->need_compare_ev); >> + qemu_thread_join(&s->thread); >> + } else { >> + colo_proxy_secondary_checkpoint(s); >> + } >> +} >> + >> +void colo_proxy_stop(int mode) >> +{ >> + Error *err = NULL; >> + qemu_foreach_netfilter(colo_proxy_stop_one, &mode, &err); >> +} >> + >> static void colo_proxy_setup(NetFilterState *nf, Error **errp) >> { >> COLOProxyState *s = FILTER_COLO_PROXY(nf); >> -- >> 1.9.1 >> >> >> >> > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK > > > . > -- Thanks zhangchen