[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/11] char: Slightly better error reporting when chardev is in us
From: |
Michael Tokarev |
Subject: |
[PULL 05/11] char: Slightly better error reporting when chardev is in use |
Date: |
Sat, 9 Mar 2024 18:57:23 +0300 |
From: Markus Armbruster <armbru@redhat.com>
Both
$ qemu-system-x86_64 -chardev null,id=chr0,mux=on -mon chardev=chr0 -mon
chardev=chr0 -mon chardev=chr0 -mon chardev=chr0 -mon chardev=chr0
and
$ qemu-system-x86_64 -chardev null,id=chr0 -mon chardev=chr0 -mon
chardev=chr0
fail with
qemu-system-x86_64: -mon chardev=chr0: Device 'chr0' is in use
Improve to
qemu-system-x86_64: -mon chardev=chr0: too many uses of multiplexed chardev
'chr0' (maximum is 4)
and
qemu-system-x86_64: -mon chardev=chr0: chardev 'chr0' is already in use
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
chardev/char-fe.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/chardev/char-fe.c b/chardev/char-fe.c
index 20222a4cad..66cee8475a 100644
--- a/chardev/char-fe.c
+++ b/chardev/char-fe.c
@@ -199,13 +199,18 @@ bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error
**errp)
MuxChardev *d = MUX_CHARDEV(s);
if (d->mux_cnt >= MAX_MUX) {
- goto unavailable;
+ error_setg(errp,
+ "too many uses of multiplexed chardev '%s'"
+ " (maximum is " stringify(MAX_MUX) ")",
+ s->label);
+ return false;
}
d->backends[d->mux_cnt] = b;
tag = d->mux_cnt++;
} else if (s->be) {
- goto unavailable;
+ error_setg(errp, "chardev '%s' is already in use", s->label);
+ return false;
} else {
s->be = b;
}
@@ -215,10 +220,6 @@ bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error
**errp)
b->tag = tag;
b->chr = s;
return true;
-
-unavailable:
- error_setg(errp, QERR_DEVICE_IN_USE, s->label);
- return false;
}
void qemu_chr_fe_deinit(CharBackend *b, bool del)
--
2.39.2
- [PULL 00/11] Trivial patches for 2024-03-09, Michael Tokarev, 2024/03/09
- [PULL 01/11] replay: Improve error messages about configuration conflicts, Michael Tokarev, 2024/03/09
- [PULL 02/11] hw/vfio/pci.c: Make some structure static, Michael Tokarev, 2024/03/09
- [PULL 03/11] hw/scsi/lsi53c895a: Fix typo in comment, Michael Tokarev, 2024/03/09
- [PULL 04/11] make-release: switch to .xz format by default, Michael Tokarev, 2024/03/09
- [PULL 05/11] char: Slightly better error reporting when chardev is in use,
Michael Tokarev <=
- [PULL 06/11] blockdev: Fix block_resize error reporting for op blockers, Michael Tokarev, 2024/03/09
- [PULL 07/11] qerror: QERR_DEVICE_IN_USE is no longer used, drop, Michael Tokarev, 2024/03/09
- [PULL 08/11] hw/cxl/cxl-cdat: Fix type of buf in ct3_load_cdat(), Michael Tokarev, 2024/03/09
- [PULL 09/11] hw/pci-bridge/cxl_upstream: Fix problem with g_steal_pointer(), Michael Tokarev, 2024/03/09
- [PULL 10/11] hw/mem/cxl_type3: Fix problem with g_steal_pointer(), Michael Tokarev, 2024/03/09
- [PULL 11/11] docs/acpi/bits: add some clarity and details while also improving formating, Michael Tokarev, 2024/03/09
- Re: [PULL 00/11] Trivial patches for 2024-03-09, Peter Maydell, 2024/03/10