aboutsummaryrefslogtreecommitdiff
path: root/console.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-09-10 10:58:49 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-09-11 10:19:49 -0500
commit6ea314d91439741e95772dfbab98b4135e04bebb (patch)
treea9988cefcac0b4426ee8be45fa212e7e82e427f2 /console.c
parent48b7649691a20063d7a97920628f234f348e4f70 (diff)
downloadqemu-6ea314d91439741e95772dfbab98b4135e04bebb.zip
qemu-6ea314d91439741e95772dfbab98b4135e04bebb.tar.gz
qemu-6ea314d91439741e95772dfbab98b4135e04bebb.tar.bz2
convert vc chardev to QemuOpts.
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> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'console.c')
-rw-r--r--console.c47
1 files changed, 23 insertions, 24 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;