[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/12] char: make monitor use new style interface
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 08/12] char: make monitor use new style interface |
Date: |
Mon, 1 Aug 2011 09:23:06 -0500 |
---
monitor.c | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/monitor.c b/monitor.c
index 38d4544..3ca211b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4747,13 +4747,6 @@ cleanup:
}
}
-static int monitor_can_read(void *opaque)
-{
- Monitor *mon = opaque;
-
- return (mon->suspend_cnt == 0) ? 1 : 0;
-}
-
static int invalid_qmp_mode(const Monitor *mon, const char *cmd_name)
{
int is_cap = compare_cmd(cmd_name, "qmp_capabilities");
@@ -5118,24 +5111,35 @@ out:
/**
* monitor_control_read(): Read and handle QMP input
*/
-static void monitor_control_read(void *opaque, const uint8_t *buf, int size)
+static void monitor_control_read(void *opaque)
{
Monitor *old_mon = cur_mon;
+ uint8_t buf[1024];
+ int size;
cur_mon = opaque;
- json_message_parser_feed(&cur_mon->mc->parser, (const char *) buf, size);
+ size = qemu_chr_fe_read(cur_mon->chr, buf, sizeof(buf));
+ json_message_parser_feed(&cur_mon->mc->parser, (const char *)buf, size);
cur_mon = old_mon;
}
-static void monitor_read(void *opaque, const uint8_t *buf, int size)
+static void monitor_read(void *opaque)
{
Monitor *old_mon = cur_mon;
+ uint8_t buf[1024];
+ int size;
int i;
cur_mon = opaque;
+ if (cur_mon->suspend_cnt > 0) {
+ return;
+ }
+
+ size = qemu_chr_fe_read(cur_mon->chr, buf, sizeof(buf));
+
if (cur_mon->rs) {
for (i = 0; i < size; i++)
readline_handle_byte(cur_mon->rs, buf[i]);
@@ -5168,8 +5172,10 @@ void monitor_resume(Monitor *mon)
{
if (!mon->rs)
return;
- if (--mon->suspend_cnt == 0)
+ if (--mon->suspend_cnt == 0) {
readline_show_prompt(mon->rs);
+ monitor_read(mon);
+ }
}
static QObject *get_qmp_greeting(void)
@@ -5273,12 +5279,11 @@ void monitor_init(CharDriverState *chr, int flags)
if (monitor_ctrl_mode(mon)) {
mon->mc = qemu_mallocz(sizeof(MonitorControl));
/* Control mode requires special handlers */
- qemu_chr_add_handlers(chr, monitor_can_read, monitor_control_read,
- monitor_control_event, mon);
+ qemu_chr_fe_set_handlers(chr, monitor_control_read, NULL,
+ monitor_control_event, mon);
qemu_chr_set_echo(chr, true);
} else {
- qemu_chr_add_handlers(chr, monitor_can_read, monitor_read,
- monitor_event, mon);
+ qemu_chr_fe_set_handlers(chr, monitor_read, NULL, monitor_event, mon);
}
QLIST_INSERT_HEAD(&mon_list, mon, entry);
--
1.7.4.1
- [Qemu-devel] [PATCH 03/12] char: introduce tx queue to enable Unix style flow control, (continued)
- [Qemu-devel] [PATCH 03/12] char: introduce tx queue to enable Unix style flow control, Anthony Liguori, 2011/08/01
- [Qemu-devel] [PATCH 07/12] char: add backend edge notification interface, Anthony Liguori, 2011/08/01
- [Qemu-devel] [PATCH 05/12] char: add read functions for backend and frontend, Anthony Liguori, 2011/08/01
- [Qemu-devel] [PATCH 06/12] char: add an edge event API for the front ends, Anthony Liguori, 2011/08/01
- [Qemu-devel] [PATCH 09/12] char: rename qemu_chr_guest_open() -> qemu_chr_fe_open(), Anthony Liguori, 2011/08/01
- [Qemu-devel] [PATCH 11/12] char: make all devices do qemu_chr_fe_open(), Anthony Liguori, 2011/08/01
- [Qemu-devel] [PATCH 08/12] char: make monitor use new style interface,
Anthony Liguori <=
- [Qemu-devel] [PATCH 10/12] char: rename qemu_chr_guest_close() -> qemu_chr_fe_close(), Anthony Liguori, 2011/08/01
- [Qemu-devel] [PATCH 12/12] char: enforce the use of qemu_chr_guest_open(), Anthony Liguori, 2011/08/01
- [Qemu-devel] [PATCH 04/12] char: introduce backend tx queue, Anthony Liguori, 2011/08/01
- Re: [Qemu-devel] [PATCH 00/12][RFC] char: add flow control and fix guest_[open|close], Alon Levy, 2011/08/01
- Re: [Qemu-devel] [PATCH 00/12][RFC] char: add flow control and fix guest_[open|close], Hans de Goede, 2011/08/01