[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/3] hw/display/vga: Report a proper error when adding a 2nd ISA
From: |
Thomas Huth |
Subject: |
[PATCH 3/3] hw/display/vga: Report a proper error when adding a 2nd ISA VGA |
Date: |
Wed, 16 Mar 2022 14:24:02 +0100 |
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>
---
hw/display/vga.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/display/vga.c b/hw/display/vga.c
index 7fc6ab7e4f..1dca3dd7c0 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -2206,6 +2206,12 @@ void 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, "A global VGA device has already been registered");
+ return;
+ }
+
memory_region_init_ram_nomigrate(&s->vram, obj, "vga.vram", s->vram_size,
&local_err);
if (local_err) {
--
2.27.0
- [PATCH 1/3] hw/display/cirrus_vga: Clean up indentation in pci_cirrus_vga_realize(), (continued)
- [PATCH 1/3] hw/display/cirrus_vga: Clean up indentation in pci_cirrus_vga_realize(), Thomas Huth, 2022/03/16
- [PATCH 2/3] hw/display: Allow vga_common_init() to return errors, Thomas Huth, 2022/03/16
- Re: [PATCH 2/3] hw/display: Allow vga_common_init() to return errors, Philippe Mathieu-Daudé, 2022/03/16
- Re: [PATCH 2/3] hw/display: Allow vga_common_init() to return errors, Thomas Huth, 2022/03/16
- Re: [PATCH 2/3] hw/display: Allow vga_common_init() to return errors, Markus Armbruster, 2022/03/16
- Re: [PATCH 2/3] hw/display: Allow vga_common_init() to return errors, Thomas Huth, 2022/03/16
- Re: [PATCH 2/3] hw/display: Allow vga_common_init() to return errors, Markus Armbruster, 2022/03/17
- Re: [PATCH 2/3] hw/display: Allow vga_common_init() to return errors, Thomas Huth, 2022/03/17
- Re: [PATCH 2/3] hw/display: Allow vga_common_init() to return errors, Markus Armbruster, 2022/03/17
[PATCH 3/3] hw/display/vga: Report a proper error when adding a 2nd ISA VGA,
Thomas Huth <=