From patchwork Thu Feb 28 07:50:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 223791 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2125B2C0086 for ; Thu, 28 Feb 2013 18:52:44 +1100 (EST) Received: from localhost ([::1]:52483 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAyIE-0002Bj-C1 for incoming@patchwork.ozlabs.org; Thu, 28 Feb 2013 02:52:42 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAyG1-0007sz-Ie for qemu-devel@nongnu.org; Thu, 28 Feb 2013 02:50:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAyFz-00076b-IN for qemu-devel@nongnu.org; Thu, 28 Feb 2013 02:50:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41883) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAyFz-000763-7i for qemu-devel@nongnu.org; Thu, 28 Feb 2013 02:50:23 -0500 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.14.4/8.14.4) with ESMTP id r1S7oM3x007509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 28 Feb 2013 02:50:22 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r1S7oD4h018814; Thu, 28 Feb 2013 02:50:14 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id DA80E452BB; Thu, 28 Feb 2013 08:50:10 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 28 Feb 2013 08:50:06 +0100 Message-Id: <1362037809-27836-15-git-send-email-kraxel@redhat.com> In-Reply-To: <1362037809-27836-1-git-send-email-kraxel@redhat.com> References: <1362037809-27836-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Anthony Liguori , Gerd Hoffmann Subject: [Qemu-devel] [PATCH 14/17] chardev: add vc support to qapi 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 This patch adds 'vc' support to qapi and also switches over the vc chardev initialization to the new qapi code path. Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 4 ++-- qapi-schema.json | 20 +++++++++++++++++++- qemu-char.c | 35 ++++++++++++++++++++++++++++++++++- ui/console.c | 26 +++++++++++++++----------- ui/gtk.c | 2 +- 5 files changed, 71 insertions(+), 16 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index c42bca6..a37cf65 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -450,9 +450,9 @@ void qemu_console_resize(DisplayState *ds, int width, int height); void qemu_console_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int dst_y, int w, int h); -typedef CharDriverState *(VcHandler)(QemuOpts *); +typedef CharDriverState *(VcHandler)(ChardevVC *vc); -CharDriverState *vc_init(QemuOpts *opts); +CharDriverState *vc_init(ChardevVC *vc); void register_vc_handler(VcHandler *handler); /* sdl.c */ diff --git a/qapi-schema.json b/qapi-schema.json index f570185..3c12122 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3231,6 +3231,23 @@ { 'type': 'ChardevSpicePort', 'data': { 'fqdn' : 'str' } } ## +# @ChardevVC: +# +# Configuration info for virtual console chardevs. +# +# @width: console width, in pixels +# @height: console height, in pixels +# @cols: console width, in chars +# @rows: console height, in chars +# +# Since: 1.5 +## +{ 'type': 'ChardevVC', 'data': { '*width' : 'int', + '*height' : 'int', + '*cols' : 'int', + '*rows' : 'int' } } + +## # @ChardevBackend: # # Configuration info for the new chardev backend. @@ -3252,7 +3269,8 @@ 'stdio' : 'ChardevStdio', 'console': 'ChardevDummy', 'spicevmc' : 'ChardevSpiceChannel', - 'spiceport' : 'ChardevSpicePort' } } + 'spiceport' : 'ChardevSpicePort', + 'vc' : 'ChardevVC' } } ## # @ChardevReturn: diff --git a/qemu-char.c b/qemu-char.c index 0d752dd..edea0f6 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2997,6 +2997,38 @@ static void qemu_chr_parse_spice_port(QemuOpts *opts, ChardevBackend *backend, backend->spiceport->fqdn = g_strdup(name); } +static void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, + Error **errp) +{ + int val; + + backend->vc = g_new0(ChardevVC, 1); + + val = qemu_opt_get_number(opts, "width", 0); + if (val != 0) { + backend->vc->has_width = true; + backend->vc->width = val; + } + + val = qemu_opt_get_number(opts, "height", 0); + if (val != 0) { + backend->vc->has_height = true; + backend->vc->height = val; + } + + val = qemu_opt_get_number(opts, "cols", 0); + if (val != 0) { + backend->vc->has_cols = true; + backend->vc->cols = val; + } + + val = qemu_opt_get_number(opts, "rows", 0); + if (val != 0) { + backend->vc->has_rows = true; + backend->vc->rows = val; + } +} + static const struct { const char *name; /* old, pre qapi */ @@ -3009,7 +3041,8 @@ static const struct { { .name = "socket", .open = qemu_chr_open_socket }, { .name = "udp", .open = qemu_chr_open_udp }, { .name = "msmouse", .kind = CHARDEV_BACKEND_KIND_MSMOUSE }, - { .name = "vc", .open = vc_init }, + { .name = "vc", .kind = CHARDEV_BACKEND_KIND_VC, + .parse = qemu_chr_parse_vc }, { .name = "memory", .open = qemu_chr_open_ringbuf }, { .name = "file", .kind = CHARDEV_BACKEND_KIND_FILE, .parse = qemu_chr_parse_file_out }, diff --git a/ui/console.c b/ui/console.c index 0d95f32..e806ada 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1537,22 +1537,26 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds) chr->init(chr); } -static CharDriverState *text_console_init(QemuOpts *opts) +static CharDriverState *text_console_init(ChardevVC *vc) { CharDriverState *chr; QemuConsole *s; - unsigned width; - unsigned height; + unsigned width = 0; + unsigned height = 0; chr = g_malloc0(sizeof(CharDriverState)); - width = qemu_opt_get_number(opts, "width", 0); - if (width == 0) - width = qemu_opt_get_number(opts, "cols", 0) * FONT_WIDTH; + if (vc->has_width) { + width = vc->width; + } else if (vc->has_cols) { + width = vc->cols * FONT_WIDTH; + } - height = qemu_opt_get_number(opts, "height", 0); - if (height == 0) - height = qemu_opt_get_number(opts, "rows", 0) * FONT_HEIGHT; + if (vc->has_height) { + height = vc->height; + } else if (vc->has_rows) { + height = vc->rows * FONT_HEIGHT; + } if (width == 0 || height == 0) { s = new_console(NULL, TEXT_CONSOLE); @@ -1575,9 +1579,9 @@ static CharDriverState *text_console_init(QemuOpts *opts) static VcHandler *vc_handler = text_console_init; -CharDriverState *vc_init(QemuOpts *opts) +CharDriverState *vc_init(ChardevVC *vc) { - return vc_handler(opts); + return vc_handler(vc); } void register_vc_handler(VcHandler *handler) diff --git a/ui/gtk.c b/ui/gtk.c index 544593e..794dab1 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -991,7 +991,7 @@ static int gd_vc_chr_write(CharDriverState *chr, const uint8_t *buf, int len) static int nb_vcs; static CharDriverState *vcs[MAX_VCS]; -static CharDriverState *gd_vc_handler(QemuOpts *opts) +static CharDriverState *gd_vc_handler(ChardevVC *unused) { CharDriverState *chr;