From 95e30b2a131ed1f94ab7a64326243943317aa18a Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Wed, 22 Aug 2018 19:19:42 +0200 Subject: chardev: mark the calls that allow an implicit mux monitor This is mostly for readability of the code. Let's make it clear which callers can create an implicit monitor when the chardev is muxed. This will also enforce a safer behaviour, as we don't really support creating monitor anywhere/anytime at the moment. Add an assert() to make sure the programmer explicitely wanted that behaviour. There are documented cases, such as: -serial/-parallel/-virtioconsole and to less extent -debugcon. Less obvious and questionable ones are -gdb, SLIRP -guestfwd and Xen console. Add a FIXME note for those, but keep the support for now. Other qemu_chr_new() callers either have a fixed parameter/filename string or do not need it, such as -qtest: * qtest.c: qtest_init() Afaik, only used by tests/libqtest.c, without mux. I don't think we support it outside of qemu testing: drop support for implicit mux monitor (qemu_chr_new() call: no implicit mux now). * hw/ All with literal @filename argument that doesn't enable mux monitor. * tests/ All with @filename argument that doesn't enable mux monitor. On a related note, the list of monitor creation places: - the chardev creators listed above: all from command line (except perhaps Xen console?) - -gdb & hmp gdbserver will create a "GDB monitor command" chardev that is wired to an HMP monitor. - -mon command line option From this short study, I would like to think that a monitor may only be created in the main thread today, though I remain skeptical :) Signed-off-by: Marc-André Lureau Reviewed-by: Markus Armbruster --- include/chardev/char.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'include/chardev/char.h') diff --git a/include/chardev/char.h b/include/chardev/char.h index 3e4fe6dad0..7becd8c80c 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -105,14 +105,27 @@ ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, * @filename: the URI * * Create a new character backend from a URI. + * Do not implicitly initialize a monitor if the chardev is muxed. * * Returns: a new character backend */ Chardev *qemu_chr_new(const char *label, const char *filename); /** - * qemu_chr_change: - * @opts: the new backend options + * qemu_chr_new_mux_mon: + * @label: the name of the backend + * @filename: the URI + * + * Create a new character backend from a URI. + * Implicitly initialize a monitor if the chardev is muxed. + * + * Returns: a new character backend + */ +Chardev *qemu_chr_new_mux_mon(const char *label, const char *filename); + +/** +* qemu_chr_change: +* @opts: the new backend options * * Change an existing character backend */ @@ -129,6 +142,7 @@ void qemu_chr_cleanup(void); * qemu_chr_new_noreplay: * @label: the name of the backend * @filename: the URI + * @permit_mux_mon: if chardev is muxed, initialize a monitor * * Create a new character backend from a URI. * Character device communications are not written @@ -136,7 +150,8 @@ void qemu_chr_cleanup(void); * * Returns: a new character backend */ -Chardev *qemu_chr_new_noreplay(const char *label, const char *filename); +Chardev *qemu_chr_new_noreplay(const char *label, const char *filename, + bool permit_mux_mon); /** * qemu_chr_be_can_write: @@ -194,7 +209,8 @@ bool qemu_chr_has_feature(Chardev *chr, ChardevFeature feature); void qemu_chr_set_feature(Chardev *chr, ChardevFeature feature); -QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename); +QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename, + bool permit_mux_mon); int qemu_chr_write(Chardev *s, const uint8_t *buf, int len, bool write_all); #define qemu_chr_write_all(s, buf, len) qemu_chr_write(s, buf, len, true) int qemu_chr_wait_connected(Chardev *chr, Error **errp); -- cgit v1.2.3-55-g7522