From: Wang yong <wang.yong155@zte.com.cn>
To: pbonzini@redhat.com, stefanha@redhat.com, famz@redhat.com,
jasowang@redhat.com
Cc: wang.yong155@zte.com.cn, wang.guang55@zte.com.cn,
zhangchen.fnst@cn.fujitsu.com, zhang.zhanghailiang@huawei.com,
lizhijian@cn.fujitsu.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] qemu-iothread: IOThread supports the GMainContext event loop
Date: Fri, 11 Aug 2017 08:29:15 +0800 [thread overview]
Message-ID: <1502411355-3943-1-git-send-email-wang.yong155@zte.com.cn> (raw)
From: Wang Yong<wang.yong155@zte.com.cn>
IOThread uses AioContext event loop and does not run a GMainContext.
Therefore,chardev cannot work in IOThread,such as the chardev is
used for colo-compare packets reception.
This patch makes the IOThread run the GMainContext event loop,
chardev and IOThread can work together.
Signed-off-by: Wang Yong<wang.yong155@zte.com.cn>
Signed-off-by: Wang Guang<wang.guang55@zte.com.cn>
---
include/sysemu/iothread.h | 1 +
iothread.c | 13 +++++++++++++
2 files changed, 14 insertions(+)
diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
index e6da1a4..ffe4e8a 100644
--- a/include/sysemu/iothread.h
+++ b/include/sysemu/iothread.h
@@ -24,6 +24,7 @@ typedef struct {
QemuThread thread;
AioContext *ctx;
+ GMainLoop *loop;
QemuMutex init_done_lock;
QemuCond init_done_cond; /* is thread initialization done? */
bool stopping;
diff --git a/iothread.c b/iothread.c
index beeb870..b6f3c3c 100644
--- a/iothread.c
+++ b/iothread.c
@@ -46,6 +46,7 @@ AioContext *qemu_get_current_aio_context(void)
static void *iothread_run(void *opaque)
{
IOThread *iothread = opaque;
+ GMainContext *context;
rcu_register_thread();
@@ -57,6 +58,15 @@ static void *iothread_run(void *opaque)
while (!atomic_read(&iothread->stopping)) {
aio_poll(iothread->ctx, true);
+
+ context = iothread->ctx->source.context;
+ if (context) {
+ iothread->loop = g_main_loop_new(context, TRUE);
+ g_main_loop_run(iothread->loop);
+
+ g_main_loop_unref(iothread->loop);
+ g_main_context_unref(context);
+ }
}
rcu_unregister_thread();
@@ -72,6 +82,9 @@ static int iothread_stop(Object *object, void *opaque)
return 0;
}
iothread->stopping = true;
+ if (iothread->loop) {
+ g_main_loop_quit(iothread->loop);
+ }
aio_notify(iothread->ctx);
qemu_thread_join(&iothread->thread);
return 0;
--
1.8.3.1
next reply other threads:[~2017-08-10 8:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-11 0:29 Wang yong [this message]
2017-08-10 8:50 ` [Qemu-devel] [PATCH] qemu-iothread: IOThread supports the GMainContext event loop Paolo Bonzini
2017-08-10 9:17 ` Fam Zheng
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=1502411355-3943-1-git-send-email-wang.yong155@zte.com.cn \
--to=wang.yong155@zte.com.cn \
--cc=famz@redhat.com \
--cc=jasowang@redhat.com \
--cc=lizhijian@cn.fujitsu.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=wang.guang55@zte.com.cn \
--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).