hmp: Fail gracefully if chardev is already in use
commit8e9119a807df510f0d2ce4cdda3078166d6e99a7
authorKevin Wolf <kwolf@redhat.com>
Mon, 24 Feb 2020 14:30:06 +0000 (24 15:30 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 6 Mar 2020 16:21:28 +0000 (6 17:21 +0100)
tree95d403e3ab3b873d8a87cec6fd4530dbc2fdffb3
parentf27a9bb3e9c3bd822243f6fc1d921f1334e37acf
hmp: Fail gracefully if chardev is already in use

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>
chardev/char.c
gdbstub.c
include/monitor/monitor.h
monitor/hmp.c
monitor/monitor.c
stubs/monitor.c
tests/test-util-sockets.c