From patchwork Tue Sep 25 10:43:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 186765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0C35B2C008F for ; Tue, 25 Sep 2012 20:44:05 +1000 (EST) Received: from localhost ([::1]:52094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGScV-0007Tn-4S for incoming@patchwork.ozlabs.org; Tue, 25 Sep 2012 06:44:03 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGScI-0007S4-DL for qemu-devel@nongnu.org; Tue, 25 Sep 2012 06:43:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TGScG-0008HU-EV for qemu-devel@nongnu.org; Tue, 25 Sep 2012 06:43:50 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:41999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGScG-0008F4-7B for qemu-devel@nongnu.org; Tue, 25 Sep 2012 06:43:48 -0400 Received: from gandalf.tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id BC58FA19A7; Tue, 25 Sep 2012 14:43:39 +0400 (MSK) Received: by gandalf.tls.msk.ru (Postfix, from userid 1000) id 76B2242ED; Tue, 25 Sep 2012 14:43:38 +0400 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Date: Tue, 25 Sep 2012 14:43:37 +0400 Message-Id: <1348569817-11178-1-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 86.62.121.231 Cc: Stefan Hajnoczi , Michael Tokarev Subject: [Qemu-devel] [PATCH] stop using stdio for monitor/serial/etc with -daemonize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Current code binds monitor and serial port to the guest console unless -nographic is specified, which is okay. But when there's no guest console (-nographic), the code tries to use stdio for the same default devices. But it does not check for -daemonize at the same time -- because when -daemonize is given, there's no point at using stdin since it will be closed down the line. However, when serial port is attached to stdin, tty control modes are changed (switching tty to raw mode), and qemu will switch to background, leaving the tty in bad state. Take -daemonize into account too, when assigning default devices, and for -nographic -daemonize case, assign them to "null" instead. This is https://bugs.launchpad.net/qemu/+bug/1024275 or http://bugs.debian.org/549195 . This patch depends on another patch, 995ee2bf469de6, "curses: don't initialize curses when qemu is daemonized", by Hitoshi Mitake, which creates is_daemonized() routine. Signed-off-by: Michael Tokarev --- vl.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/vl.c b/vl.c index 48049ef..ae1794f 100644 --- a/vl.c +++ b/vl.c @@ -3395,17 +3395,26 @@ int main(int argc, char **argv, char **envp) if (display_type == DT_NOGRAPHIC) { if (default_parallel) add_device_config(DEV_PARALLEL, "null"); - if (default_serial && default_monitor) { - add_device_config(DEV_SERIAL, "mon:stdio"); - } else if (default_virtcon && default_monitor) { - add_device_config(DEV_VIRTCON, "mon:stdio"); + if (!is_daemonized()) { + if (default_serial && default_monitor) { + add_device_config(DEV_SERIAL, "mon:stdio"); + } else if (default_virtcon && default_monitor) { + add_device_config(DEV_VIRTCON, "mon:stdio"); + } else { + if (default_serial) + add_device_config(DEV_SERIAL, "stdio"); + if (default_virtcon) + add_device_config(DEV_VIRTCON, "stdio"); + if (default_monitor) + monitor_parse("stdio", "readline"); + } } else { if (default_serial) - add_device_config(DEV_SERIAL, "stdio"); + add_device_config(DEV_SERIAL, "null"); if (default_virtcon) - add_device_config(DEV_VIRTCON, "stdio"); + add_device_config(DEV_VIRTCON, "null"); if (default_monitor) - monitor_parse("stdio", "readline"); + monitor_parse("stdio", "null"); } } else { if (default_serial)