From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XALZ5-0001AL-Od for qemu-devel@nongnu.org; Thu, 24 Jul 2014 12:08:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XALYw-00089G-M5 for qemu-devel@nongnu.org; Thu, 24 Jul 2014 12:08:19 -0400 Received: from mail-wg0-x22f.google.com ([2a00:1450:400c:c00::22f]:64643) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XALYw-00089C-GB for qemu-devel@nongnu.org; Thu, 24 Jul 2014 12:08:10 -0400 Received: by mail-wg0-f47.google.com with SMTP id b13so2986587wgh.30 for ; Thu, 24 Jul 2014 09:08:09 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 24 Jul 2014 18:08:01 +0200 Message-Id: <1406218081-27870-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH for-2.1 v2] qemu-char: ignore flow control if a PTY's slave is not connected List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: phrdina@redhat.com After commit f702e62 (serial: change retry logic to avoid concurrency, 2014-07-11), guest boot hangs if the backend is an unconnected PTY. The reason is that PTYs do not support G_IO_HUP, and serial_xmit is never called. To fix this, simply invoke serial_xmit immediately (via g_idle_source_new) when this happens. Tested-by: Pavel Hrdina Signed-off-by: Paolo Bonzini --- qemu-char.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qemu-char.c b/qemu-char.c index 7acc03f..956be49 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1168,6 +1168,9 @@ static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len) static GSource *pty_chr_add_watch(CharDriverState *chr, GIOCondition cond) { PtyCharDriver *s = chr->opaque; + if (!s->connected) { + return NULL; + } return g_io_create_watch(s->fd, cond); } @@ -3664,6 +3667,10 @@ int qemu_chr_fe_add_watch(CharDriverState *s, GIOCondition cond, } src = s->chr_add_watch(s, cond); + if (!src) { + return -EINVAL; + } + g_source_set_callback(src, (GSourceFunc)func, user_data, NULL); tag = g_source_attach(src, NULL); g_source_unref(src); -- 1.8.3.1