From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlfV1-0005aV-54 for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlfUt-0005W1-Mj for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:24 -0400 Received: from [199.232.76.173] (port=49340 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlfUt-0005VQ-Aj for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4066) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlfUs-0007Yd-LG for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:19 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8A8xHCM012351 for ; Thu, 10 Sep 2009 04:59:17 -0400 From: Gerd Hoffmann Date: Thu, 10 Sep 2009 10:58:48 +0200 Message-Id: <1252573135-27688-17-git-send-email-kraxel@redhat.com> In-Reply-To: <1252573135-27688-1-git-send-email-kraxel@redhat.com> References: <1252573135-27688-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH v2 16/23] convert tty + parport chardevs 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: -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 074fc22..e02ac5e 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 const 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 const 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; } -- 1.6.2.5