• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisionfbfc29e3bf145581e84c12ffc432ab56ce1dea0d (tree)
Zeit2019-06-18 15:14:17
AutorKevin Wolf <kwolf@redh...>
CommiterMarkus Armbruster

Log Message

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 <kwolf@redhat.com>
Message-Id: <20190613153405.24769-15-kwolf@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>

Ändern Zusammenfassung

Diff

--- a/chardev/char.c
+++ b/chardev/char.c
@@ -731,7 +731,7 @@ Chardev *qemu_chr_new_noreplay(const char *label, const char *filename,
731731
732732 if (qemu_opt_get_bool(opts, "mux", 0)) {
733733 assert(permit_mux_mon);
734- monitor_init(chr, MONITOR_USE_READLINE);
734+ monitor_init_hmp(chr, true);
735735 }
736736
737737 out:
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -3344,7 +3344,7 @@ int gdbserver_start(const char *device)
33443344 /* Initialize a monitor terminal for gdb */
33453345 mon_chr = qemu_chardev_new(NULL, TYPE_CHARDEV_GDB,
33463346 NULL, NULL, &error_abort);
3347- monitor_init(mon_chr, 0);
3347+ monitor_init_hmp(mon_chr, false);
33483348 } else {
33493349 qemu_chr_fe_deinit(&s->chr, true);
33503350 mon_chr = s->mon_chr;
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -8,19 +8,14 @@
88 extern __thread Monitor *cur_mon;
99 typedef struct MonitorHMP MonitorHMP;
1010
11-/* flags for monitor_init */
12-/* 0x01 unused */
13-#define MONITOR_USE_READLINE 0x02
14-#define MONITOR_USE_CONTROL 0x04
15-#define MONITOR_USE_PRETTY 0x08
16-
1711 #define QMP_REQ_QUEUE_LEN_MAX 8
1812
1913 bool monitor_cur_is_qmp(void);
2014
2115 void monitor_init_globals(void);
2216 void monitor_init_globals_core(void);
23-void monitor_init(Chardev *chr, int flags);
17+void monitor_init_qmp(Chardev *chr, bool pretty);
18+void monitor_init_hmp(Chardev *chr, bool use_readline);
2419 void monitor_cleanup(void);
2520
2621 int monitor_suspend(Monitor *mon);
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1395,14 +1395,14 @@ static void monitor_readline_flush(void *opaque)
13951395 monitor_flush(&mon->common);
13961396 }
13971397
1398-void monitor_init_hmp(Chardev *chr, int flags)
1398+void monitor_init_hmp(Chardev *chr, bool use_readline)
13991399 {
14001400 MonitorHMP *mon = g_new0(MonitorHMP, 1);
14011401
14021402 monitor_data_init(&mon->common, false, false, false);
14031403 qemu_chr_fe_init(&mon->common.chr, chr, &error_abort);
14041404
1405- mon->use_readline = flags & MONITOR_USE_READLINE;
1405+ mon->use_readline = use_readline;
14061406 if (mon->use_readline) {
14071407 mon->rs = readline_init(monitor_readline_printf,
14081408 monitor_readline_flush,
--- a/monitor/monitor-internal.h
+++ b/monitor/monitor-internal.h
@@ -163,9 +163,6 @@ extern int mon_refcount;
163163
164164 extern HMPCommand hmp_cmds[];
165165
166-void monitor_init_qmp(Chardev *chr, int flags);
167-void monitor_init_hmp(Chardev *chr, int flags);
168-
169166 int monitor_puts(Monitor *mon, const char *str);
170167 void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush,
171168 bool use_io_thread);
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -551,15 +551,6 @@ void monitor_data_destroy(Monitor *mon)
551551 qemu_mutex_destroy(&mon->mon_lock);
552552 }
553553
554-void monitor_init(Chardev *chr, int flags)
555-{
556- if (flags & MONITOR_USE_CONTROL) {
557- monitor_init_qmp(chr, flags);
558- } else {
559- monitor_init_hmp(chr, flags);
560- }
561-}
562-
563554 void monitor_cleanup(void)
564555 {
565556 /*
--- a/monitor/qmp.c
+++ b/monitor/qmp.c
@@ -364,18 +364,15 @@ static void monitor_qmp_setup_handlers_bh(void *opaque)
364364 monitor_list_append(&mon->common);
365365 }
366366
367-void monitor_init_qmp(Chardev *chr, int flags)
367+void monitor_init_qmp(Chardev *chr, bool pretty)
368368 {
369369 MonitorQMP *mon = g_new0(MonitorQMP, 1);
370370
371- /* Only HMP supports readline */
372- assert(!(flags & MONITOR_USE_READLINE));
373-
374371 /* Note: we run QMP monitor in I/O thread when @chr supports that */
375372 monitor_data_init(&mon->common, true, false,
376373 qemu_chr_has_feature(chr, QEMU_CHAR_FEATURE_GCONTEXT));
377374
378- mon->pretty = flags & MONITOR_USE_PRETTY;
375+ mon->pretty = pretty;
379376
380377 qemu_mutex_init(&mon->qmp_queue_lock);
381378 mon->qmp_requests = g_queue_new();
--- a/stubs/monitor.c
+++ b/stubs/monitor.c
@@ -16,7 +16,11 @@ int monitor_get_fd(Monitor *mon, const char *name, Error **errp)
1616 return -1;
1717 }
1818
19-void monitor_init(Chardev *chr, int flags)
19+void monitor_init_qmp(Chardev *chr, bool pretty)
20+{
21+}
22+
23+void monitor_init_hmp(Chardev *chr, bool use_readline)
2024 {
2125 }
2226
--- a/tests/test-util-sockets.c
+++ b/tests/test-util-sockets.c
@@ -71,7 +71,8 @@ int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
7171 */
7272 __thread Monitor *cur_mon;
7373 int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { abort(); }
74-void monitor_init(Chardev *chr, int flags) {}
74+void monitor_init_qmp(Chardev *chr, bool pretty) {}
75+void monitor_init_hmp(Chardev *chr, bool use_readline) {}
7576
7677
7778 static void test_socket_fd_pass_name_good(void)
--- a/vl.c
+++ b/vl.c
@@ -2299,25 +2299,27 @@ static int fsdev_init_func(void *opaque, QemuOpts *opts, Error **errp)
22992299 static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
23002300 {
23012301 Chardev *chr;
2302+ bool qmp;
2303+ bool pretty = false;
23022304 const char *chardev;
23032305 const char *mode;
2304- int flags;
23052306
23062307 mode = qemu_opt_get(opts, "mode");
23072308 if (mode == NULL) {
23082309 mode = "readline";
23092310 }
23102311 if (strcmp(mode, "readline") == 0) {
2311- flags = MONITOR_USE_READLINE;
2312+ qmp = false;
23122313 } else if (strcmp(mode, "control") == 0) {
2313- flags = MONITOR_USE_CONTROL;
2314+ qmp = true;
23142315 } else {
23152316 error_setg(errp, "unknown monitor mode \"%s\"", mode);
23162317 return -1;
23172318 }
23182319
2319- if (qemu_opt_get_bool(opts, "pretty", 0))
2320- flags |= MONITOR_USE_PRETTY;
2320+ if (qemu_opt_get_bool(opts, "pretty", 0)) {
2321+ pretty = true;
2322+ }
23212323
23222324 chardev = qemu_opt_get(opts, "chardev");
23232325 if (!chardev) {
@@ -2330,7 +2332,11 @@ static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
23302332 return -1;
23312333 }
23322334
2333- monitor_init(chr, flags);
2335+ if (qmp) {
2336+ monitor_init_qmp(chr, pretty);
2337+ } else {
2338+ monitor_init_hmp(chr, true);
2339+ }
23342340 return 0;
23352341 }
23362342