From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: qemu devel <qemu-devel@nongnu.org>,
Jason Wang <jasowang@redhat.com>,
Li Zhijian <lizhijian@cn.fujitsu.com>,
"eddie . dong" <eddie.dong@intel.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
zhanghailiang <zhang.zhanghailiang@huawei.com>
Subject: Re: [Qemu-devel] [RFC PATCH V7 6/7] colo-compare: introduce packet comparison thread
Date: Tue, 19 Jul 2016 11:32:41 +0800 [thread overview]
Message-ID: <578D9F59.802@cn.fujitsu.com> (raw)
In-Reply-To: <20160718083702.GI1670@redhat.com>
On 07/18/2016 04:37 PM, Daniel P. Berrange wrote:
> On Mon, Jul 18, 2016 at 03:40:49PM +0800, Zhang Chen wrote:
>> If primary packet is same with secondary packet,
>> we will send primary packet and drop secondary
>> packet, otherwise notify COLO frame to do checkpoint.
>> If primary packet comes and secondary packet not,
>> after REGULAR_PACKET_CHECK_MS milliseconds we set
>> the primary packet as old_packet,then do a checkpoint.
>>
>> Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
>> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
>> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
>> ---
>> net/colo-base.c | 1 +
>> net/colo-base.h | 3 +
>> net/colo-compare.c | 216 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>> trace-events | 2 +
>> 4 files changed, 222 insertions(+)
>>
>> +static void *colo_compare_thread(void *opaque)
>> +{
>> + GMainContext *worker_context;
>> + GMainLoop *compare_loop;
>> + CompareState *s = opaque;
>> +
>> + worker_context = g_main_context_new();
>> + g_assert(g_main_context_get_thread_default() == NULL);
>> + g_main_context_push_thread_default(worker_context);
>> + g_assert(g_main_context_get_thread_default() == worker_context);
>> +
>> + qemu_chr_add_handlers(s->chr_pri_in, compare_chr_can_read,
>> + compare_pri_chr_in, NULL, s);
>> + qemu_chr_add_handlers(s->chr_sec_in, compare_chr_can_read,
>> + compare_sec_chr_in, NULL, s);
> Looking at this I see you've used g_main_context_push_thread_default
> in order to avoid having to modify the qemu_chr_add_handlers() method
> to accept a GMainContext. Personally I think I'd favour explicit
> passing of a GMainContext, rather than modifying Qemu Char code &
> QIOChannel to magically use per-thread main context. In particular
> I'm concerned that one day other code may use the
> g_main_context_push_thread_default method for some other purpose
> but still want their char devs handled by the main thread. Your
> solution makes this impossible and adds magic which could surprise
> us in bad ways.
>
> So I think I'd rather see qemu_chr_add_handlers() modified to accept
> a GMainContext, or perhaps add a qemu_chr_add_handlers_full() method
> which takes a GMainContext, so we can avoid modifying all existing
> callers ofo qemu_chr_add_handlers. There should be no need to modify
> QIOChannel at all, since you can use qio_channel_create_watch instead
> of qio_channel_add_watch and simply attach to the context you want
> directly.
I get your point.
Considering current qemu code, I think add a flag
in CharDriverState to decide whether or not to
run g_source_attach(xxx, g_main_context_get_thread_default());
is a easy way for this.
How about this way?
Thanks for your review.
Zhang Chen
>
> Regards,
> Daniel
--
Thanks
zhangchen
next prev parent reply other threads:[~2016-07-19 3:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-18 7:40 [Qemu-devel] [RFC PATCH V7 0/7] Introduce COLO-compare Zhang Chen
2016-07-18 7:40 ` [Qemu-devel] [RFC PATCH V7 1/7] colo-compare: introduce colo compare initialization Zhang Chen
2016-07-18 7:40 ` [Qemu-devel] [RFC PATCH V7 2/7] colo-base: add colo-base to define and handle packet Zhang Chen
2016-07-18 7:40 ` [Qemu-devel] [RFC PATCH V7 3/7] Jhash: add linux kernel jhashtable in qemu Zhang Chen
2016-07-18 7:40 ` [Qemu-devel] [RFC PATCH V7 4/7] colo-compare: track connection and enqueue packet Zhang Chen
2016-07-18 7:40 ` [Qemu-devel] [RFC PATCH V7 5/7] qemu-char: Fix context for g_source_attach() Zhang Chen
2016-07-18 8:37 ` Daniel P. Berrange
2016-07-18 7:40 ` [Qemu-devel] [RFC PATCH V7 6/7] colo-compare: introduce packet comparison thread Zhang Chen
2016-07-18 8:37 ` Daniel P. Berrange
2016-07-19 3:32 ` Zhang Chen [this message]
2016-07-19 9:03 ` Daniel P. Berrange
2016-07-20 3:29 ` Zhang Chen
2016-07-18 7:40 ` [Qemu-devel] [RFC PATCH V7 7/7] colo-compare: add TCP, UDP, ICMP packet comparison Zhang Chen
-- strict thread matches above, loose matches on Subject: below --
2016-07-18 6:22 [Qemu-devel] [RFC PATCH V7 6/7] colo-compare: introduce packet comparison thread Zhang Chen
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=578D9F59.802@cn.fujitsu.com \
--to=zhangchen.fnst@cn.fujitsu.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eddie.dong@intel.com \
--cc=jasowang@redhat.com \
--cc=lizhijian@cn.fujitsu.com \
--cc=qemu-devel@nongnu.org \
--cc=zhang.zhanghailiang@huawei.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).