From patchwork Thu Sep 10 08:58:49 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 33288 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 EE343B7080 for ; Thu, 10 Sep 2009 19:41:50 +1000 (EST) Received: from localhost ([127.0.0.1]:41525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mlg9z-0007YY-G6 for incoming@patchwork.ozlabs.org; Thu, 10 Sep 2009 05:41:47 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlfUx-0005YU-JQ for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlfUq-0005Sy-Vt for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:21 -0400 Received: from [199.232.76.173] (port=49333 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlfUq-0005St-Kv for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25048) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlfUp-0007Xk-LK for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:16 -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 n8A8xEr5013356 for ; Thu, 10 Sep 2009 04:59:14 -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 n8A8x2l3027875; Thu, 10 Sep 2009 04:59:11 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id B8862700E6; Thu, 10 Sep 2009 10:58:56 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2009 10:58:49 +0200 Message-Id: <1252573135-27688-18-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> 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 v2 17/23] convert vc chardev 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 vc,id=name -chardev vc,id=name,width=pixels,height=pixels -chardev vc,id=name,cols=chars,rows=chars Signed-off-by: Gerd Hoffmann --- console.c | 47 +++++++++++++++++++++++------------------------ console.h | 2 +- qemu-char.c | 26 +++++++++++++++++++------- qemu-config.c | 12 ++++++++++++ 4 files changed, 55 insertions(+), 32 deletions(-) diff --git a/console.c b/console.c index d55e0fd..9bbef59 100644 --- a/console.c +++ b/console.c @@ -1317,16 +1317,31 @@ void console_color_init(DisplayState *ds) static int n_text_consoles; static CharDriverState *text_consoles[128]; -static char *text_console_strs[128]; +static QemuOpts *text_console_opts[128]; -static void text_console_do_init(CharDriverState *chr, DisplayState *ds, const char *p) +static void text_console_do_init(CharDriverState *chr, DisplayState *ds, QemuOpts *opts) { TextConsole *s; unsigned width; unsigned height; static int color_inited; - s = new_console(ds, (p == NULL) ? TEXT_CONSOLE : TEXT_CONSOLE_FIXED_SIZE); + width = qemu_opt_get_number(opts, "width", 0); + if (width == 0) + width = qemu_opt_get_number(opts, "cols", 0) * FONT_WIDTH; + + height = qemu_opt_get_number(opts, "height", 0); + if (height == 0) + height = qemu_opt_get_number(opts, "rows", 0) * FONT_HEIGHT; + + if (width == 0 || height == 0) { + s = new_console(ds, TEXT_CONSOLE); + width = ds_get_width(s->ds); + height = ds_get_height(s->ds); + } else { + s = new_console(ds, TEXT_CONSOLE_FIXED_SIZE); + } + if (!s) { free(chr); return; @@ -1350,23 +1365,6 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds, const c s->total_height = DEFAULT_BACKSCROLL; s->x = 0; s->y = 0; - width = ds_get_width(s->ds); - height = ds_get_height(s->ds); - if (p != NULL) { - width = strtoul(p, (char **)&p, 10); - if (*p == 'C') { - p++; - width *= FONT_WIDTH; - } - if (*p == 'x') { - p++; - height = strtoul(p, (char **)&p, 10); - if (*p == 'C') { - p++; - height *= FONT_HEIGHT; - } - } - } s->g_width = width; s->g_height = height; @@ -1391,7 +1389,7 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds, const c chr->init(chr); } -CharDriverState *text_console_init(const char *p) +CharDriverState *text_console_init(QemuOpts *opts) { CharDriverState *chr; @@ -1402,7 +1400,7 @@ CharDriverState *text_console_init(const char *p) exit(1); } text_consoles[n_text_consoles] = chr; - text_console_strs[n_text_consoles] = p ? qemu_strdup(p) : NULL; + text_console_opts[n_text_consoles] = opts; n_text_consoles++; return chr; @@ -1413,8 +1411,9 @@ void text_consoles_set_display(DisplayState *ds) int i; for (i = 0; i < n_text_consoles; i++) { - text_console_do_init(text_consoles[i], ds, text_console_strs[i]); - qemu_free(text_console_strs[i]); + text_console_do_init(text_consoles[i], ds, text_console_opts[i]); + qemu_opts_del(text_console_opts[i]); + text_console_opts[i] = NULL; } n_text_consoles = 0; diff --git a/console.h b/console.h index c8922e4..9615f56 100644 --- a/console.h +++ b/console.h @@ -303,7 +303,7 @@ void vga_hw_text_update(console_ch_t *chardata); int is_graphic_console(void); int is_fixedsize_console(void); -CharDriverState *text_console_init(const char *p); +CharDriverState *text_console_init(QemuOpts *opts); void text_consoles_set_display(DisplayState *ds); void console_select(unsigned int index); void console_color_init(DisplayState *ds); diff --git a/qemu-char.c b/qemu-char.c index e02ac5e..3240e13 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2221,7 +2221,7 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts) static QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename) { - char host[65], port[33]; + char host[65], port[33], width[8], height[8]; int pos; const char *p; QemuOpts *opts; @@ -2238,6 +2238,23 @@ static QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename) qemu_opt_set(opts, "backend", filename); return opts; } + if (strstart(filename, "vc", &p)) { + qemu_opt_set(opts, "backend", "vc"); + if (*p == ':') { + if (sscanf(p+1, "%8[0-9]x%8[0-9]", width, height) == 2) { + /* pixels */ + qemu_opt_set(opts, "width", width); + qemu_opt_set(opts, "height", height); + } else if (sscanf(p+1, "%8[0-9]Cx%8[0-9]C", width, height) == 2) { + /* chars */ + qemu_opt_set(opts, "cols", width); + qemu_opt_set(opts, "rows", height); + } else { + goto fail; + } + } + return opts; + } if (strcmp(filename, "con:") == 0) { qemu_opt_set(opts, "backend", "console"); return opts; @@ -2306,6 +2323,7 @@ static const struct { { .name = "null", .open = qemu_chr_open_null }, { .name = "socket", .open = qemu_chr_open_socket }, { .name = "msmouse", .open = qemu_chr_open_msmouse }, + { .name = "vc", .open = text_console_init }, #ifdef _WIN32 { .name = "file", .open = qemu_chr_open_win_file_out }, { .name = "pipe", .open = qemu_chr_open_win_pipe }, @@ -2376,12 +2394,6 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i return qemu_chr_open_opts(opts, init); } - if (!strcmp(filename, "vc")) { - chr = text_console_init(NULL); - } else - if (strstart(filename, "vc:", &p)) { - chr = text_console_init(p); - } else if (strstart(filename, "udp:", &p)) { chr = qemu_chr_open_udp(p); } else diff --git a/qemu-config.c b/qemu-config.c index 3b5083c..09ef481 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -112,6 +112,18 @@ QemuOptsList qemu_chardev_opts = { },{ .name = "telnet", .type = QEMU_OPT_BOOL, + },{ + .name = "width", + .type = QEMU_OPT_NUMBER, + },{ + .name = "height", + .type = QEMU_OPT_NUMBER, + },{ + .name = "cols", + .type = QEMU_OPT_NUMBER, + },{ + .name = "rows", + .type = QEMU_OPT_NUMBER, }, { /* end if list */ } },