From fbfc29e3bf145581e84c12ffc432ab56ce1dea0d Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Thu, 13 Jun 2019 17:34:04 +0200 Subject: 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: Kevin Wolf Message-Id: <20190613153405.24769-15-kwolf@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- vl.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 005468cbfb..32daa434eb 100644 --- a/vl.c +++ b/vl.c @@ -2299,25 +2299,27 @@ static int fsdev_init_func(void *opaque, QemuOpts *opts, Error **errp) static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp) { Chardev *chr; + bool qmp; + bool pretty = false; const char *chardev; const char *mode; - int flags; mode = qemu_opt_get(opts, "mode"); if (mode == NULL) { mode = "readline"; } if (strcmp(mode, "readline") == 0) { - flags = MONITOR_USE_READLINE; + qmp = false; } else if (strcmp(mode, "control") == 0) { - flags = MONITOR_USE_CONTROL; + qmp = true; } else { error_setg(errp, "unknown monitor mode \"%s\"", mode); return -1; } - if (qemu_opt_get_bool(opts, "pretty", 0)) - flags |= MONITOR_USE_PRETTY; + if (qemu_opt_get_bool(opts, "pretty", 0)) { + pretty = true; + } chardev = qemu_opt_get(opts, "chardev"); if (!chardev) { @@ -2330,7 +2332,11 @@ static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp) return -1; } - monitor_init(chr, flags); + if (qmp) { + monitor_init_qmp(chr, pretty); + } else { + monitor_init_hmp(chr, true); + } return 0; } -- cgit v1.2.3