Commit fbfc29e3 authored by Kevin Wolf's avatar Kevin Wolf Committed by Markus Armbruster
Browse files

monitor: Replace monitor_init() with monitor_init_{hmp, qmp}()



Most callers know which monitor type they want to have. Instead of
calling monitor_init() with flags that can describe both types of
monitors, make monitor_init_{hmp,qmp}() public interfaces that take
specific bools instead of flags and call these functions directly.

Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Message-Id: <20190613153405.24769-15-kwolf@redhat.com>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent 92082416
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -731,7 +731,7 @@ Chardev *qemu_chr_new_noreplay(const char *label, const char *filename,

    if (qemu_opt_get_bool(opts, "mux", 0)) {
        assert(permit_mux_mon);
        monitor_init(chr, MONITOR_USE_READLINE);
        monitor_init_hmp(chr, true);
    }

out:
+1 −1
Original line number Diff line number Diff line
@@ -3344,7 +3344,7 @@ int gdbserver_start(const char *device)
        /* Initialize a monitor terminal for gdb */
        mon_chr = qemu_chardev_new(NULL, TYPE_CHARDEV_GDB,
                                   NULL, NULL, &error_abort);
        monitor_init(mon_chr, 0);
        monitor_init_hmp(mon_chr, false);
    } else {
        qemu_chr_fe_deinit(&s->chr, true);
        mon_chr = s->mon_chr;
+2 −7
Original line number Diff line number Diff line
@@ -8,19 +8,14 @@
extern __thread Monitor *cur_mon;
typedef struct MonitorHMP MonitorHMP;

/* flags for monitor_init */
/* 0x01 unused */
#define MONITOR_USE_READLINE  0x02
#define MONITOR_USE_CONTROL   0x04
#define MONITOR_USE_PRETTY    0x08

#define QMP_REQ_QUEUE_LEN_MAX 8

bool monitor_cur_is_qmp(void);

void monitor_init_globals(void);
void monitor_init_globals_core(void);
void monitor_init(Chardev *chr, int flags);
void monitor_init_qmp(Chardev *chr, bool pretty);
void monitor_init_hmp(Chardev *chr, bool use_readline);
void monitor_cleanup(void);

int monitor_suspend(Monitor *mon);
+2 −2
Original line number Diff line number Diff line
@@ -1395,14 +1395,14 @@ static void monitor_readline_flush(void *opaque)
    monitor_flush(&mon->common);
}

void monitor_init_hmp(Chardev *chr, int flags)
void monitor_init_hmp(Chardev *chr, bool use_readline)
{
    MonitorHMP *mon = g_new0(MonitorHMP, 1);

    monitor_data_init(&mon->common, false, false, false);
    qemu_chr_fe_init(&mon->common.chr, chr, &error_abort);

    mon->use_readline = flags & MONITOR_USE_READLINE;
    mon->use_readline = use_readline;
    if (mon->use_readline) {
        mon->rs = readline_init(monitor_readline_printf,
                                monitor_readline_flush,
+0 −3
Original line number Diff line number Diff line
@@ -163,9 +163,6 @@ extern int mon_refcount;

extern HMPCommand hmp_cmds[];

void monitor_init_qmp(Chardev *chr, int flags);
void monitor_init_hmp(Chardev *chr, int flags);

int monitor_puts(Monitor *mon, const char *str);
void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush,
                       bool use_io_thread);
Loading