mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
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>
This commit is contained in:
parent
f27a9bb3e9
commit
8e9119a807
7 changed files with 18 additions and 8 deletions
|
@ -1399,12 +1399,16 @@ static void monitor_readline_flush(void *opaque)
|
|||
monitor_flush(&mon->common);
|
||||
}
|
||||
|
||||
void monitor_init_hmp(Chardev *chr, bool use_readline)
|
||||
void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp)
|
||||
{
|
||||
MonitorHMP *mon = g_new0(MonitorHMP, 1);
|
||||
|
||||
if (!qemu_chr_fe_init(&mon->common.chr, chr, errp)) {
|
||||
g_free(mon);
|
||||
return;
|
||||
}
|
||||
|
||||
monitor_data_init(&mon->common, false, false, false);
|
||||
qemu_chr_fe_init(&mon->common.chr, chr, &error_abort);
|
||||
|
||||
mon->use_readline = use_readline;
|
||||
if (mon->use_readline) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue