@@ -1322,6 +1322,13 @@ static void monitor_read(void *opaque, const uint8_t *buf, int size)
cur_mon = old_mon;
}
+static int monitor_can_read(void *opaque)
+{
+ Monitor *mon = opaque;
+
+ return !atomic_mb_read(&mon->suspend_cnt);
+}
+
static void monitor_event(void *opaque, int event)
{
Monitor *mon = opaque;
@@ -166,7 +166,6 @@ int monitor_puts(Monitor *mon, const char *str);
void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush,
bool use_io_thread);
void monitor_data_destroy(Monitor *mon);
-int monitor_can_read(void *opaque);
void monitor_list_append(Monitor *mon);
void monitor_fdsets_cleanup(void);
@@ -494,13 +494,6 @@ void monitor_resume(Monitor *mon)
trace_monitor_suspend(mon, -1);
}
-int monitor_can_read(void *opaque)
-{
- Monitor *mon = opaque;
-
- return !atomic_mb_read(&mon->suspend_cnt);
-}
-
void monitor_list_append(Monitor *mon)
{
qemu_mutex_lock(&monitor_lock);
@@ -311,6 +311,13 @@ static void handle_qmp_command(void *opaque, QObject *req, Error *err)
qemu_bh_schedule(qmp_dispatcher_bh);
}
+static int monitor_qmp_can_read(void *opaque)
+{
+ Monitor *mon = opaque;
+
+ return !atomic_mb_read(&mon->suspend_cnt);
+}
+
static void monitor_qmp_read(void *opaque, const uint8_t *buf, int size)
{
MonitorQMP *mon = opaque;
@@ -384,7 +391,7 @@ static void monitor_qmp_setup_handlers_bh(void *opaque)
assert(mon->common.use_io_thread);
context = iothread_get_g_main_context(mon_iothread);
assert(context);
- qemu_chr_fe_set_handlers(&mon->common.chr, monitor_can_read,
+ qemu_chr_fe_set_handlers(&mon->common.chr, monitor_qmp_can_read,
monitor_qmp_read, monitor_qmp_event,
NULL, &mon->common, context, true);
monitor_list_append(&mon->common);
@@ -422,7 +429,7 @@ void monitor_init_qmp(Chardev *chr, bool pretty)
monitor_qmp_setup_handlers_bh, mon);
/* The bottom half will add @mon to @mon_list */
} else {
- qemu_chr_fe_set_handlers(&mon->common.chr, monitor_can_read,
+ qemu_chr_fe_set_handlers(&mon->common.chr, monitor_qmp_can_read,
monitor_qmp_read, monitor_qmp_event,
NULL, &mon->common, NULL, true);
monitor_list_append(&mon->common);
This patch itself doesn't make sense, it is needed for the next patch. Signed-off-by: Yury Kotov <yury-kotov@yandex-team.ru> --- monitor/hmp.c | 7 +++++++ monitor/monitor-internal.h | 1 - monitor/monitor.c | 7 ------- monitor/qmp.c | 11 +++++++++-- 4 files changed, 16 insertions(+), 10 deletions(-)