From nobody Mon Apr 29 13:39:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149097866167270.18802018796089; Fri, 31 Mar 2017 09:44:21 -0700 (PDT) Received: from localhost ([::1]:41974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctzeu-0003ox-A3 for importer@patchew.org; Fri, 31 Mar 2017 12:44:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctzeA-0003WB-B6 for qemu-devel@nongnu.org; Fri, 31 Mar 2017 12:43:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctze5-0000xn-Dd for qemu-devel@nongnu.org; Fri, 31 Mar 2017 12:43:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39964) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctze5-0000wB-7m for qemu-devel@nongnu.org; Fri, 31 Mar 2017 12:43:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7DE8CC04B93A for ; Fri, 31 Mar 2017 16:43:27 +0000 (UTC) Received: from localhost (ovpn-116-169.ams2.redhat.com [10.36.116.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4AA118EDA; Fri, 31 Mar 2017 16:43:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7DE8CC04B93A Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7DE8CC04B93A From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Fri, 31 Mar 2017 17:43:22 +0100 Message-Id: <20170331164322.24020-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 31 Mar 2017 16:43:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] char: kick main loop after adding a watch X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , "Richard W . M . Jones" , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=3D1435432 Reported-by: Richard W. M. Jones Tested-by: Richard W. M. Jones Signed-off-by: Stefan Hajnoczi --- 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, GIOCond= ition cond, tag =3D g_source_attach(src, NULL); g_source_unref(src); =20 + /* 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; } =20 --=20 2.9.3