qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH v2 17/23] convert vc chardev to QemuOpts.
Date: Thu, 10 Sep 2009 10:58:49 +0200	[thread overview]
Message-ID: <1252573135-27688-18-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1252573135-27688-1-git-send-email-kraxel@redhat.com>

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 <kraxel@redhat.com>
---
 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 */ }
     },
-- 
1.6.2.5

  parent reply	other threads:[~2009-09-10  8:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-10  8:58 [Qemu-devel] [PATCH v2 00/23] switch sockets+chardev to QemuOpts Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 01/23] QemuOpts: split option parser into two functions Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 02/23] qemu-option.h include protectors Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 03/23] switch chardev to QemuOpts: infrastructure, null device Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 04/23] convert file+pipe chardevs to QemuOpts Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 05/23] sockets: add unix_connect_opts Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 06/23] sockets: add unix_listen_opts Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 07/23] sockets: add unix_*_opts for windows Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 08/23] sockets: add inet_connect_opts Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 09/23] sockets: add inet_listen_opts Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 10/23] convert unix+tcp chardevs to QemuOpts Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 11/23] convert pty chardev " Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 12/23] convert stdio " Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 13/23] convert msmouse " Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 14/23] convert braille " Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 15/23] convert windows console " Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 16/23] convert tty + parport chardevs " Gerd Hoffmann
2009-09-10  8:58 ` Gerd Hoffmann [this message]
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 18/23] convert mux chardev " Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 19/23] convert udp " Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 20/23] Allow -serial chardev:<name> Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 21/23] qdev: add parser for chardev properties Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 22/23] monitor: fix muxing Gerd Hoffmann
2009-09-10  8:58 ` [Qemu-devel] [PATCH v2 23/23] move mux focus field from CharDriverState to MuxDriver Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1252573135-27688-18-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).