[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/17] monitor: Rework terminal management
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH 10/17] monitor: Rework terminal management |
Date: |
Sat, 07 Feb 2009 19:16:28 +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 | 41 +++++++++++++++++++++--------------------
monitor.h | 2 +-
2 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/monitor.c b/monitor.c
index cc814d5..c21ea8a 100644
--- a/monitor.c
+++ b/monitor.c
@@ -67,8 +67,12 @@ typedef struct term_cmd_t {
const char *help;
} term_cmd_t;
-#define MAX_MON 4
-static CharDriverState *monitor_hd[MAX_MON];
+typedef struct MonitorTerm {
+ CharDriverState *chr;
+ LIST_ENTRY(MonitorTerm) entry;
+} MonitorTerm;
+
+static LIST_HEAD(term_list, MonitorTerm) term_list;
static int hide_banner;
static const term_cmd_t term_cmds[];
@@ -85,11 +89,13 @@ static CPUState *mon_cpu = NULL;
void monitor_flush(void)
{
- int i;
+ MonitorTerm *term;
+
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(term, &term_list, entry) {
+ if (term->chr->focus == 0)
+ qemu_chr_write(term->chr, term_outbuf, term_outbuf_index);
+ }
term_outbuf_index = 0;
}
}
@@ -2834,29 +2840,24 @@ static void term_event(void *opaque, int event)
static int is_first_init = 1;
-void monitor_init(CharDriverState *hd, int show_banner)
+void monitor_init(CharDriverState *chr, int show_banner)
{
- int i;
+ MonitorTerm *term;
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] = hd;
- break;
- }
- }
+
+ term = qemu_mallocz(sizeof(*term));
hide_banner = !show_banner;
- qemu_chr_add_handlers(hd, term_can_read, term_read, term_event, NULL);
+ term->chr = chr;
+
+ qemu_chr_add_handlers(chr, term_can_read, term_read, term_event, NULL);
+
+ LIST_INSERT_HEAD(&term_list, term, entry);
readline_start("", 0, monitor_handle_command1, NULL);
}
diff --git a/monitor.h b/monitor.h
index 8f993f1..226f76c 100644
--- a/monitor.h
+++ b/monitor.h
@@ -4,7 +4,7 @@
#include "qemu-char.h"
#include "block.h"
-void monitor_init(CharDriverState *hd, int show_banner);
+void monitor_init(CharDriverState *chr, int show_banner);
void monitor_suspend(void);
void monitor_resume(void);
- [Qemu-devel] [PATCH 08/17] monitor: Rework initial disk password retrieval, (continued)
- [Qemu-devel] [PATCH 01/17] block: Polish error handling of brdv_open2, Jan Kiszka, 2009/02/07
- [Qemu-devel] [PATCH 09/17] monitor: Simplify password input mode, Jan Kiszka, 2009/02/07
- [Qemu-devel] [PATCH 10/17] monitor: Rework terminal management,
Jan Kiszka <=
- [Qemu-devel] [PATCH 15/17] monitor: Improve mux'ed console experience, Jan Kiszka, 2009/02/07
- [Qemu-devel] [PATCH 16/17] monitor: Introduce MONITOR_USE_READLINE flag, Jan Kiszka, 2009/02/07
- [Qemu-devel] [PATCH 14/17] monitor: Decouple terminals, Jan Kiszka, 2009/02/07
[Qemu-devel] [PATCH 17/17] monitor: Pass-through for gdbstub, Jan Kiszka, 2009/02/07
[Qemu-devel] [PATCH 13/17] monitor: Introduce ReadLineState, Jan Kiszka, 2009/02/07
[Qemu-devel] [PATCH 07/17] monitor: Introduce monitor.h and readline.h, Jan Kiszka, 2009/02/07