On Fri, Mar 31, 2017 at 05:43:22PM +0100, Stefan Hajnoczi wrote: > The ISA serial port device's output can hang when the pipe on stdout > becomes full. This is a race condition where the vcpu thread executing > serial emulation code adds a watch on stdout while the main loop thread > is blocked in ppoll(2). If no timer or other event wakes up the main > loop, there will be no further output from the serial device even when > the pipe becomes writable. > > Richard W. M. Jones was able to reproduce the hang on recent versions of > guestfs-tools-c and libglib2 on Fedora 26 hosts. > > This patch kicks the main loop so the next iteration invokes ppoll(2) > with the watch fd. > > Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1435432 > Reported-by: Richard W. M. Jones <rjo...@redhat.com> > Tested-by: Richard W. M. Jones <rjo...@redhat.com> > Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com> > --- > chardev/char.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/chardev/char.c b/chardev/char.c > index 3df1163..6c99c34 100644 > --- a/chardev/char.c > +++ b/chardev/char.c > @@ -1059,6 +1059,11 @@ guint qemu_chr_fe_add_watch(CharBackend *be, > GIOCondition cond, > tag = g_source_attach(src, NULL); > g_source_unref(src); > > + /* The main loop may be in blocked waiting on events in another thread. > + * Kick it so the new watch will be added. > + */ > + qemu_notify_event(); > + > return tag; > } >
Obviously Paolo has provided further insights in the other part of this thread, but from my point of view this does appear to fix the problem. I tested it on 3 different physical machines which previously showed hangs, and on all 3 the test ran for > 30 mins [before I killed the test] which is far longer than seen before. Therefore: ACK. 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