From patchwork Mon Apr 28 15:00:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mike D. Day" X-Patchwork-Id: 343464 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6B80B1400B2 for ; Tue, 29 Apr 2014 01:01:34 +1000 (EST) Received: from localhost ([::1]:44346 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wen3k-0003oO-2d for incoming@patchwork.ozlabs.org; Mon, 28 Apr 2014 11:01:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wen3O-0003Wj-0K for qemu-devel@nongnu.org; Mon, 28 Apr 2014 11:01:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wen3I-0006ld-3S for qemu-devel@nongnu.org; Mon, 28 Apr 2014 11:01:09 -0400 Received: from mail-qg0-f48.google.com ([209.85.192.48]:61041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wen3H-0006kX-WD for qemu-devel@nongnu.org; Mon, 28 Apr 2014 11:01:04 -0400 Received: by mail-qg0-f48.google.com with SMTP id q108so7028169qgd.35 for ; Mon, 28 Apr 2014 08:01:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lx1bMaUbxbSmTsqbNFpB5VLm0QYRZrZKv3k2/zFhDeU=; b=MnOJbxClPafDDCjCzBqEnAnuxW0XedBwi9Njq7H8tab74nlqdjo2eNmGYOHIBgl7kn WeBagvbfAMpJyoXmgvBKLXPndEg/K5WF7Vv0e2tJADJCCRm2ANSn0wHfXPaJV//2xK+V yy3lSKsxCCvWzmiOSljR1IH70a7Xxyu6b8M+OAqEPtZx8wmOLnTeOoRa4an5WJsYP+ky 1BizR6tKXE8yq1XPSVhfMBADx6Nc3GZTuVHy5PQOJOWX0cKY9uV5+y8ZwyGXTa0rN7l6 Z3vdDgQayZzIaaJf/g1mDjG78KEvR366hHitYrQvVaOfhcGMf9krss8Fo5pAbP4vqFgJ WD2g== X-Gm-Message-State: ALoCoQmDwm5VZEVku+lXcB//o74V3Se6GDYaRvbCiHgcwVln9JCGiNULKpwojfDMeqvlYvqTRoj5 X-Received: by 10.224.4.5 with SMTP id 5mr33659848qap.85.1398697263128; Mon, 28 Apr 2014 08:01:03 -0700 (PDT) Received: from ncultra.org (cpe-076-182-073-192.nc.res.rr.com. [76.182.73.192]) by mx.google.com with ESMTPSA id q2sm33591941qai.20.2014.04.28.08.01.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Apr 2014 08:01:02 -0700 (PDT) From: Mike Day To: qemu-devel@nongnu.org Date: Mon, 28 Apr 2014 11:00:33 -0400 Message-Id: <1398697233-15102-1-git-send-email-ncmike@ncultra.org> X-Mailer: git-send-email 1.9.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.48 Cc: Mike Day , ambru@redhat.com, kraxel@redhat.com Subject: [Qemu-devel] [PATCH] -nographic sometimes adds an extra chardev for stdio 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 When the deprecated -nographic option is used with the -mon option in readline mode, qemu will create a second character device for stdio and place it over the stdio chardev put into place by the -mon option. This causes the terminal to stop echoeing characters upon exit from Qemu. Fix by checking for the existing chardev before adding another. Signed-off-by: Mike Day --- To reproduce, use -mon and -nographic together. I was able to reproduce it using # qemu-system-x86_64 -enable-kvm -m 1G -chardev stdio,id=mon0 \ # -mon chardev=mon0,mode=readline -nographic --- vl.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/vl.c b/vl.c index 236f95e..3104b20 100644 --- a/vl.c +++ b/vl.c @@ -93,6 +93,7 @@ int main(int argc, char **argv) #include "sysemu/kvm.h" #include "qapi/qmp/qjson.h" #include "qemu/option.h" +#include "qemu/option_int.h" #include "qemu/config-file.h" #include "qemu-options.h" #include "qmp-commands.h" @@ -524,6 +525,20 @@ static QemuOptsList qemu_mem_opts = { }, }; +static int qemu_opts_loopfun(QemuOpts *opts, void *opaque) +{ + QemuOpt *opt; + + if (!strncmp(((QemuOpt *)opts->list)->name, "mon", 3)) { + QTAILQ_FOREACH(opt, &opts->head, next) { + if (!strncmp(opt->name, "chardev", 7)) { + return 1; + } + } + } + return 0; +} + /** * Get machine options * @@ -4113,6 +4128,11 @@ int main(int argc, char **argv, char **envp) } if (display_type == DT_NOGRAPHIC) { + int have_stdio = 0; + QemuOptsList *opts = qemu_find_opts("mon"); + if (opts) { + have_stdio = qemu_opts_foreach(opts, qemu_opts_loopfun, NULL, 0); + } if (default_parallel) add_device_config(DEV_PARALLEL, "null"); if (default_serial && default_monitor) { @@ -4122,7 +4142,7 @@ int main(int argc, char **argv, char **envp) } else if (default_sclp && default_monitor) { add_device_config(DEV_SCLP, "mon:stdio"); } else { - if (default_serial) + if (default_serial && !have_stdio) add_device_config(DEV_SERIAL, "stdio"); if (default_virtcon) add_device_config(DEV_VIRTCON, "stdio");