From: "Richard W.M. Jones" <rjones@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Stefan Hajnoczi" <stefanha@redhat.com>,
qemu-devel@nongnu.org,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Frediano Ziglio" <fziglio@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] char: kick main loop after adding a watch
Date: Fri, 31 Mar 2017 18:31:01 +0100 [thread overview]
Message-ID: <20170331173101.GL30620@redhat.com> (raw)
In-Reply-To: <4de63a1a-e385-e22f-9bc4-f29d90cbdc30@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 819 bytes --]
On Fri, Mar 31, 2017 at 06:53:56PM +0200, Paolo Bonzini wrote:
> glib is expecting QEMU to use g_main_context_acquire around accesses to
> GMainContext. However QEMU is not doing that, instead it is taking its
> own mutex. So we should add g_main_context_acquire and
> g_main_context_release in the two implementations of
> os_host_main_loop_wait; these should undo the effect of Frediano's
> glib patch.
Based on this paragraph, I'm testing the attached patch, and it does
also appear to solve the hanging serial port problem.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://libguestfs.org
[-- Attachment #2: 0001-main-loop-Acquire-main_context-lock-around-os_host_m.patch --]
[-- Type: text/plain, Size: 1656 bytes --]
>From d46afa25dae0f1d057cfac3a0b6ae94771be51f2 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 31 Mar 2017 18:29:01 +0100
Subject: [PATCH] main-loop: Acquire main_context lock around
os_host_main_loop_wait.
---
util/main-loop.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/util/main-loop.c b/util/main-loop.c
index 4534c89..19cad6b 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -218,9 +218,12 @@ static void glib_pollfds_poll(void)
static int os_host_main_loop_wait(int64_t timeout)
{
+ GMainContext *context = g_main_context_default();
int ret;
static int spin_counter;
+ g_main_context_acquire(context);
+
glib_pollfds_fill(&timeout);
/* If the I/O thread is very busy or we are incorrectly busy waiting in
@@ -256,6 +259,9 @@ static int os_host_main_loop_wait(int64_t timeout)
}
glib_pollfds_poll();
+
+ g_main_context_release(context);
+
return ret;
}
#else
@@ -412,12 +418,15 @@ static int os_host_main_loop_wait(int64_t timeout)
fd_set rfds, wfds, xfds;
int nfds;
+ g_main_context_acquire(context);
+
/* XXX: need to suppress polling by better using win32 events */
ret = 0;
for (pe = first_polling_entry; pe != NULL; pe = pe->next) {
ret |= pe->func(pe->opaque);
}
if (ret != 0) {
+ g_main_context_release(context);
return ret;
}
@@ -472,6 +481,8 @@ static int os_host_main_loop_wait(int64_t timeout)
g_main_context_dispatch(context);
}
+ g_main_context_release(context);
+
return select_ret || g_poll_ret;
}
#endif
--
2.9.3
next prev parent reply other threads:[~2017-03-31 17:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-31 16:43 [Qemu-devel] [PATCH] char: kick main loop after adding a watch Stefan Hajnoczi
2017-03-31 16:53 ` Paolo Bonzini
2017-03-31 17:31 ` Richard W.M. Jones [this message]
2017-03-31 17:31 ` Paolo Bonzini
2017-03-31 17:40 ` Richard W.M. Jones
2017-04-01 10:08 ` Paolo Bonzini
2017-04-03 13:20 ` Stefan Hajnoczi
2017-03-31 17:09 ` Richard W.M. Jones
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=20170331173101.GL30620@redhat.com \
--to=rjones@redhat.com \
--cc=fziglio@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).