[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 15/17] monitor: Improve mux'ed console experience
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH 15/17] monitor: Improve mux'ed console experience |
Date: |
Sat, 07 Feb 2009 19:16:29 +0100 |
User-agent: |
StGIT/0.14.2 |
Up to now, you never really knew if you already switched the console
after pressing CTRL-A C or if you mistyped it again. This patch
clarifies the situation by providing a prompt in a new line and
injecting a linebreak when switching away again. For this purpose, the
two events CHR_EVENT_MUX_IN and CHR_EVENT_MUX_OUT are introduced and
distributed on focus switches.
Signed-off-by: Jan Kiszka <address@hidden>
---
monitor.c | 26 ++++++++++++++++++++------
qemu-char.c | 11 +++++++++--
qemu-char.h | 8 +++++---
3 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/monitor.c b/monitor.c
index 498b223..2306b10 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2868,15 +2868,29 @@ static void term_event(void *opaque, int event)
{
MonitorTerm *old_term = cur_term;
- if (event != CHR_EVENT_RESET)
- return;
-
cur_term = opaque;
- monitor_printf("QEMU %s monitor - type 'help' for more information\n",
- QEMU_VERSION);
- monitor_resume(cur_term);
+ switch (event) {
+ case CHR_EVENT_MUX_IN:
+ readline_restart(cur_term->rs);
+ monitor_resume(cur_term);
+ monitor_flush();
+ break;
+ case CHR_EVENT_MUX_OUT:
+ if (cur_term->suspend_cnt == 0)
+ monitor_printf("\n");
+ monitor_flush();
+ monitor_suspend();
+ break;
+
+ case CHR_EVENT_RESET:
+ monitor_printf("QEMU %s monitor - type 'help' for more information\n",
+ QEMU_VERSION);
+ if (cur_term->chr->focus == 0)
+ monitor_resume(cur_term);
+ break;
+ }
cur_term = old_term;
}
diff --git a/qemu-char.c b/qemu-char.c
index db2fb44..d107c53 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -294,6 +294,12 @@ static void mux_print_help(CharDriverState *chr)
}
}
+static void mux_chr_send_event(MuxDriver *d, int mux_nr, int event)
+{
+ if (d->chr_event[mux_nr])
+ d->chr_event[mux_nr](d->ext_opaque[mux_nr], event);
+}
+
static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
{
if (d->term_got_escape) {
@@ -325,9 +331,11 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver
*d, int ch)
break;
case 'c':
/* Switch to the next registered device */
+ mux_chr_send_event(d, chr->focus, CHR_EVENT_MUX_OUT);
chr->focus++;
if (chr->focus >= d->mux_cnt)
chr->focus = 0;
+ mux_chr_send_event(d, chr->focus, CHR_EVENT_MUX_IN);
break;
case 't':
term_timestamps = !term_timestamps;
@@ -397,8 +405,7 @@ static void mux_chr_event(void *opaque, int event)
/* Send the event to all registered listeners */
for (i = 0; i < d->mux_cnt; i++)
- if (d->chr_event[i])
- d->chr_event[i](d->ext_opaque[i], event);
+ mux_chr_send_event(d, i, event);
}
static void mux_chr_update_read_handler(CharDriverState *chr)
diff --git a/qemu-char.h b/qemu-char.h
index bc0fcf3..b936244 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -4,9 +4,11 @@
#include "sys-queue.h"
/* character device */
-#define CHR_EVENT_BREAK 0 /* serial break char */
-#define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
-#define CHR_EVENT_RESET 2 /* new connection established */
+#define CHR_EVENT_BREAK 0 /* serial break char */
+#define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
+#define CHR_EVENT_RESET 2 /* new connection established */
+#define CHR_EVENT_MUX_IN 3 /* mux-focus was set to this terminal */
+#define CHR_EVENT_MUX_OUT 4 /* mux-focus will move on */
#define CHR_IOCTL_SERIAL_SET_PARAMS 1
- [Qemu-devel] [PATCH 04/17] monitor: Report encrypted disks in snapshot mode, (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, 2009/02/07
- [Qemu-devel] [PATCH 15/17] monitor: Improve mux'ed console experience,
Jan Kiszka <=
- [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
[Qemu-devel] [PATCH 12/17] monitor: Rework modal password input, Jan Kiszka, 2009/02/07