From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXgnr-0007oK-1A for qemu-devel@nongnu.org; Sun, 21 Feb 2016 22:04:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXgnm-0004pE-9t for qemu-devel@nongnu.org; Sun, 21 Feb 2016 22:04:50 -0500 Received: from [59.151.112.132] (port=36524 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXgnk-0004hZ-Nv for qemu-devel@nongnu.org; Sun, 21 Feb 2016 22:04:46 -0500 References: <1450780978-19123-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> <1450780978-19123-4-git-send-email-zhangchen.fnst@cn.fujitsu.com> <20160219195700.GI2412@work-vm> From: Zhang Chen Message-ID: <56CA7AD3.40206@cn.fujitsu.com> Date: Mon, 22 Feb 2016 11:04:51 +0800 MIME-Version: 1.0 In-Reply-To: <20160219195700.GI2412@work-vm> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH v2 03/10] Colo-proxy: add colo-proxy framework 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:57 AM, Dr. David Alan Gilbert wrote: > * Zhang Chen (zhangchen.fnst@cn.fujitsu.com) wrote: >> From: zhangchen >> >> +static void colo_proxy_setup(NetFilterState *nf, Error **errp) >> +{ >> + COLOProxyState *s = FILTER_COLO_PROXY(nf); >> + >> + if (!s->addr) { >> + error_setg(errp, "filter colo_proxy needs 'addr' property set!"); >> + return; >> + } >> + >> + if (nf->direction != NET_FILTER_DIRECTION_ALL) { >> + error_setg(errp, "colo need queue all packet," >> + "please startup colo-proxy with queue=all\n"); >> + return; >> + } >> + >> + s->sockfd = -1; >> + s->hashtable_size = 0; >> + colo_do_checkpoint = false; >> + qemu_event_init(&s->need_compare_ev, false); >> + >> + s->incoming_queue = qemu_new_net_queue(qemu_netfilter_pass_to_next, nf); > I found that I had to be careful that this queue got flushed. If the packet > can't be sent immediately, then the packet only gets sent if another > packet is added to the queue later. I added a state change notifier to > flush it when the VM started running (this is more of a problem in my hybrid > mode case). > > Note also that the queue is not protected by locks; so take care since packets > are sent from both the comparison thread and the colo thread (when it flushes) > and I think it's read by the main thread as well potentially as packets are sent. > > Dave > Hi, Dave. Thanks for your review, I will pay attention to this problem in the following modules. and We have split colo-proxy to filter-mirror, filter-redirector, filter-rewriter and colo-compare about jason's comments. The detail please look at the discussion about "[RFC PATCH v2 00/10] Add colo-proxy based on netfilter" . If you have time, please review it. Thanks zhangchen >> + colo_conn_hash = g_hash_table_new_full(connection_key_hash, >> + connection_key_equal, >> + g_free, >> + connection_destroy); >> + g_queue_init(&s->conn_list); >> +} >> + >> +static void colo_proxy_class_init(ObjectClass *oc, void *data) >> +{ >> + NetFilterClass *nfc = NETFILTER_CLASS(oc); >> + >> + nfc->setup = colo_proxy_setup; >> + nfc->cleanup = colo_proxy_cleanup; >> + nfc->receive_iov = colo_proxy_receive_iov; >> +} >> + >> +static int colo_proxy_get_mode(Object *obj, Error **errp) >> +{ >> + COLOProxyState *s = FILTER_COLO_PROXY(obj); >> + >> + return s->colo_mode; >> +} >> + >> +static void >> +colo_proxy_set_mode(Object *obj, int mode, Error **errp) >> +{ >> + COLOProxyState *s = FILTER_COLO_PROXY(obj); >> + >> + s->colo_mode = mode; >> +} >> + >> +static char *colo_proxy_get_addr(Object *obj, Error **errp) >> +{ >> + COLOProxyState *s = FILTER_COLO_PROXY(obj); >> + >> + return g_strdup(s->addr); >> +} >> + >> +static void >> +colo_proxy_set_addr(Object *obj, const char *value, Error **errp) >> +{ >> + COLOProxyState *s = FILTER_COLO_PROXY(obj); >> + g_free(s->addr); >> + s->addr = g_strdup(value); >> + if (!s->addr) { >> + error_setg(errp, "colo_proxy needs 'addr'" >> + "property set!"); >> + return; >> + } >> +} >> + >> +static void colo_proxy_init(Object *obj) >> +{ >> + object_property_add_enum(obj, "mode", "COLOMode", COLOMode_lookup, >> + colo_proxy_get_mode, colo_proxy_set_mode, NULL); >> + object_property_add_str(obj, "addr", colo_proxy_get_addr, >> + colo_proxy_set_addr, NULL); >> +} >> + >> +static void colo_proxy_fini(Object *obj) >> +{ >> + COLOProxyState *s = FILTER_COLO_PROXY(obj); >> + g_free(s->addr); >> +} >> + >> +static const TypeInfo colo_proxy_info = { >> + .name = TYPE_FILTER_COLO_PROXY, >> + .parent = TYPE_NETFILTER, >> + .class_init = colo_proxy_class_init, >> + .instance_init = colo_proxy_init, >> + .instance_finalize = colo_proxy_fini, >> + .instance_size = sizeof(COLOProxyState), >> +}; >> + >> +static void register_types(void) >> +{ >> + type_register_static(&colo_proxy_info); >> +} >> + >> +type_init(register_types); >> diff --git a/net/colo-proxy.h b/net/colo-proxy.h >> new file mode 100644 >> index 0000000..affc117 >> --- /dev/null >> +++ b/net/colo-proxy.h >> @@ -0,0 +1,24 @@ >> +/* >> + * COarse-grain LOck-stepping Virtual Machines for Non-stop Service (COLO) >> + * (a.k.a. Fault Tolerance or Continuous Replication) >> + * >> + * Copyright (c) 2015 HUAWEI TECHNOLOGIES CO., LTD. >> + * Copyright (c) 2015 FUJITSU LIMITED >> + * Copyright (c) 2015 Intel Corporation >> + * >> + * Author: Zhang Chen >> + * >> + * This work is licensed under the terms of the GNU GPL, version 2 or >> + * later. See the COPYING file in the top-level directory. >> + */ >> + >> + >> +#ifndef QEMU_COLO_PROXY_H >> +#define QEMU_COLO_PROXY_H >> + >> +int colo_proxy_start(int mode); >> +void colo_proxy_stop(int mode); >> +int colo_proxy_do_checkpoint(int mode); >> +bool colo_proxy_query_checkpoint(void); >> + >> +#endif /* QEMU_COLO_PROXY_H */ >> -- >> 1.9.1 >> >> >> >> > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK > > > . > -- Thanks zhangchen