[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH V7 5/7] qemu-char: Fix context for g_source_atta
From: |
Zhang Chen |
Subject: |
[Qemu-devel] [RFC PATCH V7 5/7] qemu-char: Fix context for g_source_attach() |
Date: |
Mon, 18 Jul 2016 15:40:48 +0800 |
We want to poll and handle chardev in another thread
other than main loop. But qemu_chr_add_handlers() can only
work for global default context other than thread default context.
So we use g_source_attach(xx, g_main_context_get_thread_default())
replace g_source_attach(xx, NULL) to attach g_source.
Comments from jason.
Cc: Daniel P . Berrange <address@hidden>
Cc: Paolo Bonzini <address@hidden>
Signed-off-by: Zhang Chen <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
---
io/channel.c | 2 +-
qemu-char.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/io/channel.c b/io/channel.c
index 692eb17..cd25677 100644
--- a/io/channel.c
+++ b/io/channel.c
@@ -146,7 +146,7 @@ guint qio_channel_add_watch(QIOChannel *ioc,
g_source_set_callback(source, (GSourceFunc)func, user_data, notify);
- id = g_source_attach(source, NULL);
+ id = g_source_attach(source, g_main_context_get_thread_default());
g_source_unref(source);
return id;
diff --git a/qemu-char.c b/qemu-char.c
index b597ee1..ed7e1f7 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -860,7 +860,7 @@ static gboolean io_watch_poll_prepare(GSource *source, gint
*timeout_)
iwp->src = qio_channel_create_watch(
iwp->ioc, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL);
g_source_set_callback(iwp->src, iwp->fd_read, iwp->opaque, NULL);
- g_source_attach(iwp->src, NULL);
+ g_source_attach(iwp->src, g_main_context_get_thread_default());
} else {
g_source_destroy(iwp->src);
g_source_unref(iwp->src);
@@ -919,7 +919,7 @@ static guint io_add_watch_poll(QIOChannel *ioc,
iwp->fd_read = (GSourceFunc) fd_read;
iwp->src = NULL;
- tag = g_source_attach(&iwp->parent, NULL);
+ tag = g_source_attach(&iwp->parent, g_main_context_get_thread_default());
g_source_unref(&iwp->parent);
return tag;
}
@@ -3983,7 +3983,7 @@ int qemu_chr_fe_add_watch(CharDriverState *s,
GIOCondition cond,
}
g_source_set_callback(src, (GSourceFunc)func, user_data, NULL);
- tag = g_source_attach(src, NULL);
+ tag = g_source_attach(src, g_main_context_get_thread_default());
g_source_unref(src);
return tag;
--
2.7.4
- [Qemu-devel] [RFC PATCH V7 0/7] Introduce COLO-compare, Zhang Chen, 2016/07/18
- [Qemu-devel] [RFC PATCH V7 0/7] Introduce COLO-compare, Zhang Chen, 2016/07/18
- [Qemu-devel] [RFC PATCH V7 2/7] colo-base: add colo-base to define and handle packet, Zhang Chen, 2016/07/18
- [Qemu-devel] [RFC PATCH V7 1/7] colo-compare: introduce colo compare initialization, Zhang Chen, 2016/07/18
- [Qemu-devel] [RFC PATCH V7 3/7] Jhash: add linux kernel jhashtable in qemu, Zhang Chen, 2016/07/18
- [Qemu-devel] [RFC PATCH V7 5/7] qemu-char: Fix context for g_source_attach(),
Zhang Chen <=
- [Qemu-devel] [RFC PATCH V7 4/7] colo-compare: track connection and enqueue packet, Zhang Chen, 2016/07/18
- [Qemu-devel] [RFC PATCH V7 6/7] colo-compare: introduce packet comparison thread, Zhang Chen, 2016/07/18
[Qemu-devel] [RFC PATCH V7 7/7] colo-compare: add TCP, UDP, ICMP packet comparison, Zhang Chen, 2016/07/18