From patchwork Mon Sep 7 16:06:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 33108 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 30186B7093 for ; Tue, 8 Sep 2009 02:55:12 +1000 (EST) Received: from localhost ([127.0.0.1]:37813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MkhUj-0001HE-EV for incoming@patchwork.ozlabs.org; Mon, 07 Sep 2009 12:55:09 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mkgk5-0007cX-7U for qemu-devel@nongnu.org; Mon, 07 Sep 2009 12:06:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mkgjz-0007Yt-74 for qemu-devel@nongnu.org; Mon, 07 Sep 2009 12:06:55 -0400 Received: from [199.232.76.173] (port=34969 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mkgjy-0007YV-Cq for qemu-devel@nongnu.org; Mon, 07 Sep 2009 12:06:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32243) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mkgjx-0003Xq-PP for qemu-devel@nongnu.org; Mon, 07 Sep 2009 12:06:50 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n87G6mox010217 for ; Mon, 7 Sep 2009 12:06:49 -0400 Received: from zweiblum.home.kraxel.org (vpn2-9-74.ams2.redhat.com [10.36.9.74]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n87G6fWi021534; Mon, 7 Sep 2009 12:06:43 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 88A71700EF; Mon, 7 Sep 2009 18:06:26 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 7 Sep 2009 18:06:18 +0200 Message-Id: <1252339585-27797-17-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> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 16/23] convert tty + parport chardevs to QemuOpts. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org new cmd line syntax: -chardev tty,id=name,path=/dev/tty* -chardev parport,id=name,path=/dev/parport* Signed-off-by: Gerd Hoffmann --- qemu-char.c | 57 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 32 insertions(+), 25 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 5ec864e..6066c08 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1146,8 +1146,9 @@ static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg) return 0; } -static CharDriverState *qemu_chr_open_tty(const char *filename) +static CharDriverState *qemu_chr_open_tty(QemuOpts *opts) { + const char *filename = qemu_opt_get(opts, "path"); CharDriverState *chr; int fd; @@ -1279,8 +1280,9 @@ static void pp_close(CharDriverState *chr) qemu_chr_event(chr, CHR_EVENT_CLOSED); } -static CharDriverState *qemu_chr_open_pp(const char *filename) +static CharDriverState *qemu_chr_open_pp(QemuOpts *opts) { + const char *filename = qemu_opt_get(opts, "path"); CharDriverState *chr; ParallelCharDriver *drv; int fd; @@ -1348,8 +1350,9 @@ static int pp_ioctl(CharDriverState *chr, int cmd, void *arg) return 0; } -static CharDriverState *qemu_chr_open_pp(const char *filename) +static CharDriverState *qemu_chr_open_pp(QemuOpts *opts) { + const char *filename = qemu_opt_get(opts, "path"); CharDriverState *chr; int fd; @@ -1567,8 +1570,9 @@ static int win_chr_poll(void *opaque) return 0; } -static CharDriverState *qemu_chr_open_win(const char *filename) +static CharDriverState *qemu_chr_open_win(QemuOpts *opts) { + const char *filename = qemu_opt_get(opts, "path"); CharDriverState *chr; WinCharState *s; @@ -2238,6 +2242,11 @@ static QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename) qemu_opt_set(opts, "backend", "console"); return opts; } + if (strstart(filename, "COM", NULL)) { + qemu_opt_set(opts, "backend", "serial"); + qemu_opt_set(opts, "path", filename); + return opts; + } if (strstart(filename, "file:", &p)) { qemu_opt_set(opts, "backend", "file"); qemu_opt_set(opts, "path", p); @@ -2272,6 +2281,17 @@ static QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename) goto fail; return opts; } + if (strstart(filename, "/dev/parport", NULL) || + strstart(filename, "/dev/ppi", NULL)) { + qemu_opt_set(opts, "backend", "parport"); + qemu_opt_set(opts, "path", filename); + return opts; + } + if (strstart(filename, "/dev/", NULL)) { + qemu_opt_set(opts, "backend", "tty"); + qemu_opt_set(opts, "path", filename); + return opts; + } fail: fprintf(stderr, "%s: fail on \"%s\"\n", __FUNCTION__, filename); @@ -2290,6 +2310,7 @@ static struct { { .name = "file", .open = qemu_chr_open_win_file_out }, { .name = "pipe", .open = qemu_chr_open_win_pipe }, { .name = "console", .open = qemu_chr_open_win_con }, + { .name = "serial", .open = qemu_chr_open_win }, #else { .name = "file", .open = qemu_chr_open_file_out }, { .name = "pipe", .open = qemu_chr_open_pipe }, @@ -2299,6 +2320,13 @@ static struct { #ifdef CONFIG_BRLAPI { .name = "braille", .open = chr_baum_init }, #endif +#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ + || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) + { .name = "tty", .open = qemu_chr_open_tty }, +#endif +#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) + { .name = "parport", .open = qemu_chr_open_pp }, +#endif }; CharDriverState *qemu_chr_open_opts(QemuOpts *opts, @@ -2366,27 +2394,6 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i printf("Unable to open driver: %s\n", p); } } else -#ifndef _WIN32 -#if defined(__linux__) - if (strstart(filename, "/dev/parport", NULL)) { - chr = qemu_chr_open_pp(filename); - } else -#elif defined(__FreeBSD__) || defined(__DragonFly__) - if (strstart(filename, "/dev/ppi", NULL)) { - chr = qemu_chr_open_pp(filename); - } else -#endif -#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ - || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) - if (strstart(filename, "/dev/", NULL)) { - chr = qemu_chr_open_tty(filename); - } else -#endif -#else /* !_WIN32 */ - if (strstart(filename, "COM", NULL)) { - chr = qemu_chr_open_win(filename); - } else -#endif { chr = NULL; }