qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Cc: zhanghailiang <zhang.zhanghailiang@huawei.com>,
	Li Zhijian <lizhijian@cn.fujitsu.com>,
	Gui jianfeng <guijianfeng@cn.fujitsu.com>,
	Jason Wang <jasowang@redhat.com>,
	"eddie.dong" <eddie.dong@intel.com>,
	qemu devel <qemu-devel@nongnu.org>,
	Huang peng <peter.huangpeng@huawei.com>,
	Gong lei <arei.gonglei@huawei.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	jan.kiszka@siemens.com,
	Yang Hongyang <hongyang.yang@easystack.cn>
Subject: Re: [Qemu-devel] [RFC PATCH v2 03/10] Colo-proxy: add colo-proxy framework
Date: Fri, 19 Feb 2016 19:57:01 +0000	[thread overview]
Message-ID: <20160219195700.GI2412@work-vm> (raw)
In-Reply-To: <1450780978-19123-4-git-send-email-zhangchen.fnst@cn.fujitsu.com>

* Zhang Chen (zhangchen.fnst@cn.fujitsu.com) wrote:
> From: zhangchen <zhangchen.fnst@cn.fujitsu.com>
> 

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


> +    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 <zhangchen.fnst@cn.fujitsu.com>
> + *
> + * 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

  reply	other threads:[~2016-02-19 19:57 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 10:42 [Qemu-devel] [RFC PATCH v2 00/10] Add colo-proxy based on netfilter Zhang Chen
2015-12-22 10:42 ` [Qemu-devel] [RFC PATCH v2 01/10] Init colo-proxy object " Zhang Chen
2016-01-15 18:21   ` Dr. David Alan Gilbert
2016-01-18  7:08     ` Zhang Chen
2015-12-22 10:42 ` [Qemu-devel] [RFC PATCH v2 02/10] Jhash: add linux kernel jhashtable in qemu Zhang Chen
2016-01-08 12:08   ` Dr. David Alan Gilbert
2016-01-11  1:49     ` Zhang Chen
2016-01-11 12:50       ` Dr. David Alan Gilbert
2016-01-12  1:58         ` Zhang Chen
2016-01-12  8:58           ` Dr. David Alan Gilbert
2015-12-22 10:42 ` [Qemu-devel] [RFC PATCH v2 03/10] Colo-proxy: add colo-proxy framework Zhang Chen
2016-02-19 19:57   ` Dr. David Alan Gilbert [this message]
2016-02-22  3:04     ` Zhang Chen
2015-12-22 10:42 ` [Qemu-devel] [RFC PATCH v2 04/10] Colo-proxy: add data structure and jhash func Zhang Chen
2015-12-22 10:42 ` [Qemu-devel] [RFC PATCH v2 05/10] net/colo-proxy: Add colo interface to use proxy Zhang Chen
2016-02-19 19:58   ` Dr. David Alan Gilbert
2016-02-22  3:08     ` Zhang Chen
2015-12-22 10:42 ` [Qemu-devel] [RFC PATCH v2 06/10] net/colo-proxy: add socket used by forward func Zhang Chen
2016-02-19 20:01   ` Dr. David Alan Gilbert
2016-02-22  5:51     ` Zhang Chen
2015-12-22 10:42 ` [Qemu-devel] [RFC PATCH v2 07/10] net/colo-proxy: Add packet enqueue & handle func Zhang Chen
2015-12-22 10:42 ` [Qemu-devel] [RFC PATCH v2 08/10] net/colo-proxy: Handle packet and connection Zhang Chen
2016-02-19 20:04   ` Dr. David Alan Gilbert
2016-02-22  6:41     ` Zhang Chen
2016-02-22 19:54       ` Dr. David Alan Gilbert
2016-02-23 17:58       ` Dr. David Alan Gilbert
2016-02-24  2:01         ` Zhang Chen
2015-12-22 10:42 ` [Qemu-devel] [RFC PATCH v2 09/10] net/colo-proxy: Compare pri pkt to sec pkt Zhang Chen
2016-02-19 20:07   ` Dr. David Alan Gilbert
2015-12-22 10:42 ` [Qemu-devel] [RFC PATCH v2 10/10] net/colo-proxy: Colo-proxy do checkpoint and clear Zhang Chen
2015-12-29  6:31 ` [Qemu-devel] [RFC PATCH v2 00/10] Add colo-proxy based on netfilter Zhang Chen
2015-12-29  6:58   ` Jason Wang
2015-12-29  7:08     ` Zhang Chen
2015-12-31  2:36 ` Jason Wang
2015-12-31  8:02   ` Li Zhijian
2016-01-04  2:08     ` Jason Wang
2015-12-31  8:40   ` Zhang Chen
2016-01-04  5:37     ` Jason Wang
2016-01-04  8:16       ` Zhang Chen
2016-01-04  9:46         ` Jason Wang
2016-01-04 11:17           ` Zhang Chen
2016-01-06  5:16             ` Jason Wang
2016-01-18  7:05               ` Zhang Chen
2016-01-18  9:29                 ` Jason Wang
2016-01-20  3:29                   ` Zhang Chen
2016-01-20  6:54                     ` Jason Wang
2016-01-20  7:44                       ` Wen Congyang
2016-01-20  9:20                         ` Jason Wang
2016-01-20  9:49                           ` Wen Congyang
2016-01-20 10:03                             ` Jason Wang
2016-01-20 10:34                               ` Wen Congyang
2016-01-22  5:33                                 ` Jason Wang
2016-01-22  5:57                                   ` Wen Congyang
2016-01-20 10:01                       ` Wen Congyang
2016-01-20 10:19                         ` Jason Wang
2016-01-20 10:30                           ` Wen Congyang
2016-01-22  3:15                             ` Jason Wang
2016-01-22  3:28                               ` Wen Congyang
2016-01-22  5:41                                 ` Jason Wang
2016-01-22  5:56                                   ` Wen Congyang
2016-01-22  6:21                                     ` Jason Wang
2016-01-22  6:47                                       ` Wen Congyang
2016-01-22  7:42                                         ` Jason Wang
2016-01-22  7:46                                           ` Wen Congyang
2016-01-27 15:22                                             ` Eric Blake
2016-01-04 16:52           ` Dr. David Alan Gilbert
2016-01-06  5:20             ` Jason Wang
2016-01-06  9:10               ` Dr. David Alan Gilbert
2016-01-08 11:19 ` Dr. David Alan Gilbert
2016-01-11  1:30   ` Zhang Chen
2016-01-11 12:59     ` Dr. David Alan Gilbert
2016-01-12  7:32       ` Zhang Chen
2016-02-29 20:04 ` Dr. David Alan Gilbert
2016-03-01  2:39   ` Li Zhijian
2016-03-01 10:48     ` Dr. David Alan Gilbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160219195700.GI2412@work-vm \
    --to=dgilbert@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=eddie.dong@intel.com \
    --cc=guijianfeng@cn.fujitsu.com \
    --cc=hongyang.yang@easystack.cn \
    --cc=jan.kiszka@siemens.com \
    --cc=jasowang@redhat.com \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=zhang.zhanghailiang@huawei.com \
    --cc=zhangchen.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).