From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Thomas Huth <thuth@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: [PULL 6/6] hw/display/vga: Report a proper error when adding a 2nd ISA VGA
Date: Fri, 18 Mar 2022 14:56:34 +0100 [thread overview]
Message-ID: <20220318135634.2851040-7-kraxel@redhat.com> (raw)
In-Reply-To: <20220318135634.2851040-1-kraxel@redhat.com>
From: Thomas Huth <thuth@redhat.com>
QEMU currently abort()s if the user tries to add a second ISA VGA
device, for example:
$ ./qemu-system-x86_64 -device isa-vga -device isa-vga
RAMBlock "vga.vram" already registered, abort!
Aborted (core dumped)
$ ./qemu-system-x86_64 -device isa-cirrus-vga -device isa-cirrus-vga
RAMBlock "vga.vram" already registered, abort!
Aborted (core dumped)
$ ./qemu-system-mips64el -M pica61 -device isa-vga
RAMBlock "vga.vram" already registered, abort!
Aborted (core dumped)
Such a crash should never happen just because of giving bad parameters
at the command line. Let's return a proper error message instead.
(The idea is based on an original patch by Jose R. Ziviani for the
isa-vga device, but this now fixes it for the isa-cirrus-vga device, too)
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/44
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20220317083027.16688-4-thuth@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/display/vga.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/display/vga.c b/hw/display/vga.c
index ae960235963b..a7a291fa2089 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -2206,6 +2206,12 @@ bool vga_common_init(VGACommonState *s, Object *obj, Error **errp)
s->vbe_size_mask = s->vbe_size - 1;
s->is_vbe_vmstate = 1;
+
+ if (s->global_vmstate && qemu_ram_block_by_name("vga.vram")) {
+ error_setg(errp, "Only one global VGA device can be used at a time");
+ return false;
+ }
+
memory_region_init_ram_nomigrate(&s->vram, obj, "vga.vram", s->vram_size,
&local_err);
if (local_err) {
--
2.35.1
next prev parent reply other threads:[~2022-03-18 14:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-18 13:56 [PULL 0/6] Fixes 20220318 patches Gerd Hoffmann
2022-03-18 13:56 ` [PULL 1/6] ui/gtk: Ignore 2- and 3-button press events Gerd Hoffmann
2022-03-18 13:56 ` [PULL 2/6] ui: avoid unnecessary memory operations in vnc_refresh_server_surface() Gerd Hoffmann
2022-03-18 13:56 ` [PULL 3/6] audio/mixeng: Do not declare unused variables Gerd Hoffmann
2022-03-18 13:56 ` [PULL 4/6] hw/display/cirrus_vga: Clean up indentation in pci_cirrus_vga_realize() Gerd Hoffmann
2022-03-18 13:56 ` [PULL 5/6] hw/display: Allow vga_common_init() to return errors Gerd Hoffmann
2022-03-18 13:56 ` Gerd Hoffmann [this message]
2022-03-19 14:16 ` [PULL 0/6] Fixes 20220318 patches Peter Maydell
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=20220318135634.2851040-7-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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).