From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>,
"Jose R . Ziviani" <jziviani@suse.de>,
"Michael S. Tsirkin" <mst@redhat.com>,
qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>,
John Snow <jsnow@redhat.com>
Subject: Re: [PATCH-for-6.2 2/2] hw/display: Do not allow multiple identical VGA devices
Date: Fri, 19 Nov 2021 10:10:19 +0000 [thread overview]
Message-ID: <YZd4CwBciBOsjhrR@redhat.com> (raw)
In-Reply-To: <20211118192020.61245-3-philmd@redhat.com>
On Thu, Nov 18, 2021 at 08:20:20PM +0100, Philippe Mathieu-Daudé wrote:
> vga_common_init() create a MemoryRegion named "vga.vram",
> used as a singleton for the device class. When creating
> the same device type multiple times, we get:
>
> $ qemu-system-mips64 -M pica61 -device isa-cirrus-vga
> RAMBlock "vga.vram" already registered, abort!
> Aborted (core dumped)
Admittedly that would Callers that aren't ready to
>
> Commit 7852a77f598 ("vga: don't abort when adding a duplicate
> isa-vga device") added a check for a single device, generalize
> it to all VGA devices which call vga_common_init():
Not all current VGA devices abort though
$ qemu-system-x86_64 -device cirrus-vga -device cirrus-vga
runs without aborting.
Your goal was to eliminate the abort() scenario, which
makes sense, but we hit other scenarios too.
How about we instead have vmstate_register_ram() gain
an "Error **errp" so it can propagate the failure into
vga_common_init rather than aborting. That would
ensure we only affect scenarios that curently abort
and nothing more.
Other callers can pass &error_abort if they dont want
to gracefully handle this scenario.
>
> $ qemu-system-mips64 -M pica61 -device isa-cirrus-vga
> qemu-system-mips64: -device isa-cirrus-vga: at most one isa-cirrus-vga device is permitted
>
> Reported-by: John Snow <jsnow@redhat.com>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/44
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/display/vga-isa.c | 9 ---------
> hw/display/vga.c | 13 +++++++++++++
> 2 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/hw/display/vga-isa.c b/hw/display/vga-isa.c
> index 2782012196a..b930c8d2667 100644
> --- a/hw/display/vga-isa.c
> +++ b/hw/display/vga-isa.c
> @@ -62,15 +62,6 @@ static void vga_isa_realizefn(DeviceState *dev, Error **errp)
> MemoryRegion *vga_io_memory;
> const MemoryRegionPortio *vga_ports, *vbe_ports;
>
> - /*
> - * make sure this device is not being added twice, if so
> - * exit without crashing qemu
> - */
> - if (object_resolve_path_type("", TYPE_ISA_VGA, NULL)) {
> - error_setg(errp, "at most one %s device is permitted", TYPE_ISA_VGA);
> - return;
> - }
> -
> s->global_vmstate = true;
> if (!vga_common_init(s, OBJECT(dev), errp)) {
> return;
> diff --git a/hw/display/vga.c b/hw/display/vga.c
> index a6759c7e934..8f0d5cc9019 100644
> --- a/hw/display/vga.c
> +++ b/hw/display/vga.c
> @@ -2172,6 +2172,19 @@ bool vga_common_init(VGACommonState *s, Object *obj, Error **errp)
> {
> int i, j, v, b;
>
> + if (obj) {
> + const char *typename = object_get_typename(obj);
> +
> + /*
> + * make sure this device is not being added twice,
> + * if so exit without crashing qemu
> + */
> + if (object_resolve_path_type("", typename, NULL)) {
> + error_setg(errp, "at most one %s device is permitted", typename);
> + return false;
> + }
> + }
> +
> for(i = 0;i < 256; i++) {
> v = 0;
> for(j = 0; j < 8; j++) {
> --
> 2.31.1
>
>
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2021-11-19 10:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-18 19:20 [PATCH-for-6.2 0/2] hw/display: Do not allow multiple (identical) VGA devices Philippe Mathieu-Daudé
2021-11-18 19:20 ` [PATCH-for-6.2 1/2] hw/display: Add Error* handle to vga_common_init() Philippe Mathieu-Daudé
2021-11-18 19:20 ` [PATCH-for-6.2 2/2] hw/display: Do not allow multiple identical VGA devices Philippe Mathieu-Daudé
2021-11-19 9:20 ` Paolo Bonzini
2021-11-19 9:42 ` Philippe Mathieu-Daudé
2021-11-19 10:10 ` Daniel P. Berrangé [this message]
2021-11-19 8:21 ` [PATCH-for-6.2 0/2] hw/display: Do not allow multiple (identical) " Mark Cave-Ayland
2021-11-19 9:49 ` Philippe Mathieu-Daudé
2021-11-19 9:58 ` Thomas Huth
2021-11-19 10:17 ` Philippe Mathieu-Daudé
2021-11-19 11:10 ` Thomas Huth
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=YZd4CwBciBOsjhrR@redhat.com \
--to=berrange@redhat.com \
--cc=jsnow@redhat.com \
--cc=jziviani@suse.de \
--cc=kraxel@redhat.com \
--cc=mst@redhat.com \
--cc=philmd@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).