Received: from eggs.gnu.org ([208.118.235.92]:50799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGVVv-0000pK-2M for qemu-devel@nongnu.org; Tue, 25 Sep 2012 09:49:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TGVVt-0004JQ-HP for qemu-devel@nongnu.org; Tue, 25 Sep 2012 09:49:26 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:46596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGVVt-0004JJ-9r for qemu-devel@nongnu.org; Tue, 25 Sep 2012 09:49:25 -0400 Message-ID: <5061B662.2030005@msgid.tls.msk.ru> Date: Tue, 25 Sep 2012 17:49:22 +0400 From: Michael Tokarev MIME-Version: 1.0 References: <1348569817-11178-1-git-send-email-mjt@msgid.tls.msk.ru> <50619B33.7030903@msgid.tls.msk.ru> In-Reply-To: <50619B33.7030903@msgid.tls.msk.ru> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] stop using stdio for monitor/serial/etc with -daemonize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Stefan Hajnoczi , qemu-devel@nongnu.org On 25.09.2012 15:53, Michael Tokarev wrote: > On 25.09.2012 15:23, Peter Maydell wrote: [] >> Would it be possible to condense this chain of ifs down a bit >> by having a variable which gets appropriately set to >> "stdio", "null" or "vc:80Cx24C" and then used in a single >> set of add_device_config() calls? > > I think it can be, yes. Will try again :) I don't think it is better (just an example, it doesn't quite work yet): /* Create default monitor, serial, parallel and virtcon devices. */ /* reuse optarg variable */ optarg = NULL; if (display_type != DT_NOGRAPHIC) { /* regular case, all devices directed to the guest console */ optarg = "vc:80Cx24C"; } else if (is_daemonized()) { /* nographic and daemonize, everything goes to null */ optarg = "null"; } else { /* -nographic and no -daemonize */ /* can't have both serial and virtcon on stdio */ 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 { optarg = "stdio"; } } if (optarg && default_serial) { add_device_config(DEV_SERIAL, optarg); } if (default_parallel) { add_device_config(DEV_PARALLEL, display_type != DT_NOGRAPHIC ? "null" : optarg); } if (optarg && default_monitor) { monitor_parse(optarg, "readline"); } if (optarg && default_virtcon) { add_device_config(DEV_VIRTCON, optarg); } /mjt