From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mkgk3-0007be-4R for qemu-devel@nongnu.org; Mon, 07 Sep 2009 12:06:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mkgjw-0007Xb-Sf for qemu-devel@nongnu.org; Mon, 07 Sep 2009 12:06:53 -0400 Received: from [199.232.76.173] (port=34966 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mkgjw-0007XJ-Iq for qemu-devel@nongnu.org; Mon, 07 Sep 2009 12:06:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19163) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mkgjw-0003XG-0N for qemu-devel@nongnu.org; Mon, 07 Sep 2009 12:06:48 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n87G6lYD010201 for ; Mon, 7 Sep 2009 12:06:47 -0400 From: Gerd Hoffmann Date: Mon, 7 Sep 2009 18:06:20 +0200 Message-Id: <1252339585-27797-19-git-send-email-kraxel@redhat.com> In-Reply-To: <1252339585-27797-1-git-send-email-kraxel@redhat.com> References: <1252339585-27797-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 18/23] convert mux chardev to QemuOpts. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann new cmd line syntax: you can add mux=1 to any chardev to enable muxing, then attach it multiple times, like this: -chardev pty,name=mux,mux=on Signed-off-by: Gerd Hoffmann --- qemu-char.c | 32 +++++++++++++++++++++----------- 1 files changed, 21 insertions(+), 11 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 429ba2d..5442226 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2230,6 +2230,11 @@ static QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename) if (NULL == opts) return NULL; + if (strstart(filename, "mon:", &p)) { + filename = p; + qemu_opt_set(opts, "mux", "on"); + } + if (strcmp(filename, "null") == 0 || strcmp(filename, "pty") == 0 || strcmp(filename, "msmouse") == 0 || @@ -2378,8 +2383,18 @@ CharDriverState *qemu_chr_open_opts(QemuOpts *opts, if (!chr->filename) chr->filename = qemu_strdup(qemu_opt_get(opts, "backend")); chr->init = init; - chr->label = qemu_strdup(qemu_opts_id(opts)); TAILQ_INSERT_TAIL(&chardevs, chr, next); + + if (qemu_opt_get_bool(opts, "mux", 0)) { + CharDriverState *base = chr; + int len = strlen(qemu_opts_id(opts)) + 6; + base->label = qemu_malloc(len); + snprintf(base->label, len, "%s-base", qemu_opts_id(opts)); + chr = qemu_chr_open_mux(base); + chr->filename = base->filename; + TAILQ_INSERT_TAIL(&chardevs, chr, next); + } + chr->label = qemu_strdup(qemu_opts_id(opts)); return chr; } @@ -2391,21 +2406,16 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i opts = qemu_chr_parse_compat(label, filename); if (opts) { - return qemu_chr_open_opts(opts, init); + chr = qemu_chr_open_opts(opts, init); + if (qemu_opt_get_bool(opts, "mux", 0)) { + monitor_init(chr, MONITOR_USE_READLINE); + } + return chr; } if (strstart(filename, "udp:", &p)) { chr = qemu_chr_open_udp(p); } else - if (strstart(filename, "mon:", &p)) { - chr = qemu_chr_open(label, p, NULL); - if (chr) { - chr = qemu_chr_open_mux(chr); - monitor_init(chr, MONITOR_USE_READLINE); - } else { - printf("Unable to open driver: %s\n", p); - } - } else { chr = NULL; } -- 1.6.2.5