提交 87127161 编写于 作者: A aliguori

monitor: Rework terminal management (Jan Kiszka)

Remove the static MAX_MON limit by managing monitor terminals in a
linked list.
Signed-off-by: NJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6712 c046a42c-6fe2-441c-8c8c-71466251a162
上级 376253ec
...@@ -67,8 +67,12 @@ typedef struct mon_cmd_t { ...@@ -67,8 +67,12 @@ typedef struct mon_cmd_t {
const char *help; const char *help;
} mon_cmd_t; } mon_cmd_t;
#define MAX_MON 4 struct Monitor {
static CharDriverState *monitor_hd[MAX_MON]; CharDriverState *chr;
LIST_ENTRY(Monitor) entry;
};
static LIST_HEAD(mon_list, Monitor) mon_list;
static int hide_banner; static int hide_banner;
static const mon_cmd_t mon_cmds[]; static const mon_cmd_t mon_cmds[];
...@@ -79,7 +83,7 @@ static int term_outbuf_index; ...@@ -79,7 +83,7 @@ static int term_outbuf_index;
static BlockDriverCompletionFunc *password_completion_cb; static BlockDriverCompletionFunc *password_completion_cb;
static void *password_opaque; static void *password_opaque;
Monitor *cur_mon; Monitor *cur_mon = NULL;
static void monitor_start_input(void); static void monitor_start_input(void);
...@@ -93,11 +97,13 @@ static void monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, ...@@ -93,11 +97,13 @@ static void monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
void monitor_flush(Monitor *mon) void monitor_flush(Monitor *mon)
{ {
int i; Monitor *m;
if (term_outbuf_index > 0) { if (term_outbuf_index > 0) {
for (i = 0; i < MAX_MON; i++) LIST_FOREACH(m, &mon_list, entry) {
if (monitor_hd[i] && monitor_hd[i]->focus == 0) if (m->chr->focus == 0)
qemu_chr_write(monitor_hd[i], term_outbuf, term_outbuf_index); qemu_chr_write(m->chr, term_outbuf, term_outbuf_index);
}
term_outbuf_index = 0; term_outbuf_index = 0;
} }
} }
...@@ -2921,27 +2927,24 @@ static int is_first_init = 1; ...@@ -2921,27 +2927,24 @@ static int is_first_init = 1;
void monitor_init(CharDriverState *chr, int show_banner) void monitor_init(CharDriverState *chr, int show_banner)
{ {
int i; Monitor *mon;
if (is_first_init) { if (is_first_init) {
key_timer = qemu_new_timer(vm_clock, release_keys, NULL); 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; is_first_init = 0;
} }
for (i = 0; i < MAX_MON; i++) {
if (monitor_hd[i] == NULL) { mon = qemu_mallocz(sizeof(*mon));
monitor_hd[i] = chr;
break;
}
}
hide_banner = !show_banner; 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); readline_start("", 0, monitor_command_cb, NULL);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册