aboutsummaryrefslogtreecommitdiff
path: root/monitor/hmp.c
AgeCommit message (Collapse)AuthorFilesLines
2020-03-06hmp: Fail gracefully if chardev is already in useKevin Wolf1-2/+6
Trying to attach a HMP monitor to a chardev that is already in use results in a crash because monitor_init_hmp() passes &error_abort to qemu_chr_fe_init(): $ ./x86_64-softmmu/qemu-system-x86_64 --chardev stdio,id=foo --mon foo --mon foo QEMU 4.2.50 monitor - type 'help' for more information (qemu) Unexpected error in qemu_chr_fe_init() at chardev/char-fe.c:220: qemu-system-x86_64: --mon foo: Device 'foo' is in use Abgebrochen (Speicherabzug geschrieben) Fix this by allowing monitor_init_hmp() to return an error and passing any error in qemu_chr_fe_init() to its caller instead of aborting. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20200224143008.13362-19-kwolf@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2020-01-08chardev: Use QEMUChrEvent enum in IOEventHandler typedefPhilippe Mathieu-Daudé1-1/+1
The Chardev events are listed in the QEMUChrEvent enum. By using the enum in the IOEventHandler typedef we: - make the IOEventHandler type more explicit (this handler process out-of-band information, while the IOReadHandler is in-band), - help static code analyzers. This patch was produced with the following spatch script: @match@ expression backend, opaque, context, set_open; identifier fd_can_read, fd_read, fd_event, be_change; @@ qemu_chr_fe_set_handlers(backend, fd_can_read, fd_read, fd_event, be_change, opaque, context, set_open); @depends on match@ identifier opaque, event; identifier match.fd_event; @@ static -void fd_event(void *opaque, int event) +void fd_event(void *opaque, QEMUChrEvent event) { ... } Then the typedef was modified manually in include/chardev/char-fe.h. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Corey Minyard <cminyard@mvista.com> Acked-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20191218172009.8868-15-philmd@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-01-07monitor/hmp: Explicit we ignore a QEMUChrEvent in IOEventHandlerPhilippe Mathieu-Daudé1-0/+4
The Chardev events are listed in the QEMUChrEvent enum. To be able to use this enum in the IOEventHandler typedef, we need to explicit an event ignored by this frontend, to silent the following GCC warning: CC monitor/hmp.o monitor/hmp.c: In function ‘monitor_event’: monitor/hmp.c:1330:5: error: enumeration value ‘CHR_EVENT_BREAK’ not handled in switch [-Werror=switch] 1330 | switch (event) { | ^~~~~~ cc1: all warnings being treated as errors Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20191218172009.8868-13-philmd@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-08-16sysemu: Split sysemu/runstate.h off sysemu/sysemu.hMarkus Armbruster1-1/+1
sysemu/sysemu.h is a rather unfocused dumping ground for stuff related to the system-emulator. Evidence: * It's included widely: in my "build everything" tree, changing sysemu/sysemu.h still triggers a recompile of some 1100 out of 6600 objects (not counting tests and objects that don't depend on qemu/osdep.h, down from 5400 due to the previous two commits). * It pulls in more than a dozen additional headers. Split stuff related to run state management into its own header sysemu/runstate.h. Touching sysemu/sysemu.h now recompiles some 850 objects. qemu/uuid.h also drops from 1100 to 850, and qapi/qapi-types-run-state.h from 4400 to 4200. Touching new sysemu/runstate.h recompiles some 500 objects. Since I'm touching MAINTAINERS to add sysemu/runstate.h anyway, also add qemu/main-loop.h. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20190812052359.30071-30-armbru@redhat.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> [Unbreak OS-X build]
2019-06-18monitor: Replace monitor_init() with monitor_init_{hmp, qmp}()Kevin Wolf1-2/+2
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>
2019-06-18monitor: Split Monitor.flags into separate boolsKevin Wolf1-3/+3
Monitor.flags contains three different flags: One to distinguish HMP from QMP; one specific to HMP (MONITOR_USE_READLINE) that is ignored with QMP; and another one specific to QMP (MONITOR_USE_PRETTY) that is ignored with HMP. Split the flags field into three bools and move them to the right subclass. Flags are still in use for the monitor_init() interface. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20190613153405.24769-14-kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2019-06-18monitor: Split out monitor/hmp.cKevin Wolf1-0/+1417
Move HMP infrastructure from monitor/misc.c to monitor/hmp.c. This is code that can be shared for all targets, so compile it only once. The amount of function and particularly extern variables in monitor_int.h is probably a bit larger than it needs to be, but this way no non-trivial code modifications are needed. The interfaces between HMP and the monitor core can be cleaned up later. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20190613153405.24769-12-kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Comment reformatted to make checkpatch.pl happy, #include <dirent.h> moved to fix Windows build, superfluous #include dropped] Signed-off-by: Markus Armbruster <armbru@redhat.com>