[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 13/19] monitor: Rework terminal management
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH v2 13/19] monitor: Rework terminal management |
Date: |
Sat, 21 Feb 2009 19:29:17 +0100 |
User-agent: |
StGIT/0.14.2 |
Remove the static MAX_MON limit by managing monitor terminals in a
linked list.
Signed-off-by: Jan Kiszka <address@hidden>
---
monitor.c | 43 +++++++++++++++++++++++--------------------
1 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/monitor.c b/monitor.c
index 2936222..dad9c66 100644
--- a/monitor.c
+++ b/monitor.c
@@ -67,8 +67,12 @@ typedef struct mon_cmd_t {
const char *help;
} mon_cmd_t;
-#define MAX_MON 4
-static CharDriverState *monitor_hd[MAX_MON];
+struct Monitor {
+ CharDriverState *chr;
+ LIST_ENTRY(Monitor) entry;
+};
+
+static LIST_HEAD(mon_list, Monitor) mon_list;
static int hide_banner;
static const mon_cmd_t mon_cmds[];
@@ -79,7 +83,7 @@ static int term_outbuf_index;
static BlockDriverCompletionFunc *password_completion_cb;
static void *password_opaque;
-Monitor *cur_mon;
+Monitor *cur_mon = NULL;
static void monitor_start_input(void);
@@ -93,11 +97,13 @@ static void monitor_read_password(Monitor *mon,
ReadLineFunc *readline_func,
void monitor_flush(Monitor *mon)
{
- int i;
+ Monitor *m;
+
if (term_outbuf_index > 0) {
- for (i = 0; i < MAX_MON; i++)
- if (monitor_hd[i] && monitor_hd[i]->focus == 0)
- qemu_chr_write(monitor_hd[i], term_outbuf, term_outbuf_index);
+ LIST_FOREACH(m, &mon_list, entry) {
+ if (m->chr->focus == 0)
+ qemu_chr_write(m->chr, term_outbuf, term_outbuf_index);
+ }
term_outbuf_index = 0;
}
}
@@ -2890,27 +2896,24 @@ static int is_first_init = 1;
void monitor_init(CharDriverState *chr, int show_banner)
{
- int i;
+ Monitor *mon;
if (is_first_init) {
key_timer = qemu_new_timer(vm_clock, release_keys, NULL);
- if (!key_timer)
- return;
- for (i = 0; i < MAX_MON; i++) {
- monitor_hd[i] = NULL;
- }
is_first_init = 0;
}
- for (i = 0; i < MAX_MON; i++) {
- if (monitor_hd[i] == NULL) {
- monitor_hd[i] = chr;
- break;
- }
- }
+
+ mon = qemu_mallocz(sizeof(*mon));
hide_banner = !show_banner;
- qemu_chr_add_handlers(chr, term_can_read, term_read, term_event, cur_mon);
+ mon->chr = chr;
+
+ qemu_chr_add_handlers(chr, term_can_read, term_read, term_event, mon);
+
+ LIST_INSERT_HEAD(&mon_list, mon, entry);
+ if (!cur_mon)
+ cur_mon = mon;
readline_start("", 0, monitor_command_cb, NULL);
}
- [Qemu-devel] [PATCH v2 06/19] monitor: Use reasonable default virtual console size, (continued)
- [Qemu-devel] [PATCH v2 06/19] monitor: Use reasonable default virtual console size, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 01/19] char: Fix initial reset, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 03/19] block: Polish error handling of brdv_open2, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 05/19] block: Introduce bdrv_get_encrypted_filename, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 09/19] monitor: Simplify password input mode, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 08/19] monitor: Rework early disk password inquiry, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 07/19] monitor: Report encrypted disks in snapshot mode, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 14/19] monitor: Drop banner hiding, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 11/19] monitor: Rework modal password input, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 19/19] monitor: Pass-through for gdbstub, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 13/19] monitor: Rework terminal management,
Jan Kiszka <=
- [Qemu-devel] [PATCH v2 10/19] monitor: Break out readline_show_prompt, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 16/19] monitor: Decouple terminals, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 18/19] monitor: Introduce MONITOR_USE_READLINE flag, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 15/19] monitor: Introduce ReadLineState, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 12/19] monitor: Rework API, Jan Kiszka, 2009/02/21
- [Qemu-devel] [PATCH v2 17/19] monitor: Improve mux'ed console experience, Jan Kiszka, 2009/02/21
- Re: [Qemu-devel] [PATCH v2 00/19] monitor rework, Anthony Liguori, 2009/02/27