OSDN Git Service

ui/console: only walk QemuGraphicConsoles in qemu_console_is_multihead()
authorLaszlo Ersek <lersek@redhat.com>
Wed, 13 Sep 2023 14:49:57 +0000 (16:49 +0200)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 3 Oct 2023 11:04:56 +0000 (15:04 +0400)
commit4ce2f97c000629531553328e1871b56312a210cf
tree77ee52e2e8f247ca0373d36642074b562f21c806
parent845fff1f83ac87f592b5b0fa01c37844ea8cc9f9
ui/console: only walk QemuGraphicConsoles in qemu_console_is_multihead()

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>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20230913144959.41891-3-lersek@redhat.com>
ui/console.c