From: Laszlo Ersek <lersek@redhat.com>
To: lersek@redhat.com, qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>
Subject: [PATCH 2/4] ui/console: only walk QemuGraphicConsoles in qemu_console_is_multihead()
Date: Wed, 13 Sep 2023 16:49:57 +0200 [thread overview]
Message-ID: <20230913144959.41891-3-lersek@redhat.com> (raw)
In-Reply-To: <20230913144959.41891-1-lersek@redhat.com>
qemu_console_is_multihead() declares the console "c" a "multihead" console
if there are two different consoles in the system that (a) both reference
"c->device", and (b) have different "c->head" numbers. In effect, if at
least two consoles exist that are different heads of the same device that
underlies "c".
Commit 58d5870845c6 ("ui/console: move graphic fields to
QemuGraphicConsole", 2023-09-04) pushed the "device" and "head" members
from the QemuConsole base class down to the QemuGraphicConsole subclass,
adjusting the referring QOM properties accordingly as well. As a result,
the "device" property lookup in qemu_console_is_multihead() now crashes,
in case the candidate console being investigated for criterion (a) is not
a QemuGraphicConsole instance:
> Unexpected error in object_property_find_err() at qom/object.c:1314:
> qemu: Property 'qemu-fixed-text-console.device' not found
> Aborted (core dumped)
This is effectively an unchecked downcast. Make it checked: only consider
such console candidates that are themselves QemuGraphicConsole instances.
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com> (odd fixer:Graphics)
Cc: Gerd Hoffmann <kraxel@redhat.com> (odd fixer:Graphics)
Fixes: 58d5870845c6
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
ui/console.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ui/console.c b/ui/console.c
index adacc3473140..2ee65207b430 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -2373,6 +2373,9 @@ static bool qemu_console_is_multihead(DeviceState *dev)
uint32_t h;
QTAILQ_FOREACH(con, &consoles, next) {
+ if (!QEMU_IS_GRAPHIC_CONSOLE(con)) {
+ continue;
+ }
obj = object_property_get_link(OBJECT(con),
"device", &error_abort);
if (DEVICE(obj) != dev) {
next prev parent reply other threads:[~2023-09-13 14:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 14:49 [PATCH 0/4] ui/console: multihead: fix crash, simplify logic Laszlo Ersek
2023-09-13 14:49 ` [PATCH 1/4] ui/console: make qemu_console_is_multihead() static Laszlo Ersek
2023-09-13 15:12 ` Philippe Mathieu-Daudé
2023-09-13 14:49 ` Laszlo Ersek [this message]
2023-09-13 14:49 ` [PATCH 3/4] ui/console: eliminate QOM properties from qemu_console_is_multihead() Laszlo Ersek
2023-09-13 14:49 ` [PATCH 4/4] ui/console: sanitize search in qemu_graphic_console_is_multihead() Laszlo Ersek
2023-09-15 11:50 ` [PATCH 0/4] ui/console: multihead: fix crash, simplify logic Marc-André Lureau
2023-09-25 15:36 ` Laszlo Ersek
2023-09-26 8:00 ` Marc-André Lureau
2023-09-29 7:57 ` Mark Cave-Ayland
2023-09-30 21:28 ` Laszlo Ersek
2023-10-01 6:15 ` Mark Cave-Ayland
2023-10-01 9:31 ` Laszlo Ersek
2023-10-01 9:50 ` Michael Tokarev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230913144959.41891-3-lersek@redhat.com \
--to=lersek@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).