From: Markus Armbruster <armbru@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks.
Date: Wed, 12 Aug 2009 19:00:09 +0200 [thread overview]
Message-ID: <87d4713r3a.fsf@pike.pond.sub.org> (raw)
In-Reply-To: <1250092766-23986-1-git-send-email-kraxel@redhat.com> (Gerd Hoffmann's message of "Wed\, 12 Aug 2009 17\:59\:26 +0200")
Gerd Hoffmann <kraxel@redhat.com> writes:
> Sorry folks, but it has to be. One more of these invasive qdev patches.
>
> We have a serious design bug in the qdev interface: device init
> callbacks can't signal failure because the init() callback has no
> return value. This patch fixes it.
Yupp.
> We have already one case in-tree where this is needed:
> Try -device virtio-blk-pci (without drive= specified) and watch qemu
> segfault. This patch fixes it.
>
> With usb+scsi being converted to qdev we'll get more devices where the
> init callback can fail for various reasons.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
I verified that we either
* change a function returning void to return int instead, or
* insert return 0 at the end of a function, or
* change F() to return F(), for some F() that now returns int, or
* insert return -1 instead of continuing to a crash, in
virtio_blk_init_pci(), or
* handle a failed device init(), in qdev_device_add().
[...]
> diff --git a/hw/vga.c b/hw/vga.c
> index 4a0f197..12c0424 100644
> --- a/hw/vga.c
> +++ b/hw/vga.c
> @@ -2480,7 +2480,7 @@ static void pci_vga_write_config(PCIDevice *d,
> s->map_addr = 0;
> }
>
> -static void pci_vga_initfn(PCIDevice *dev)
> +static int pci_vga_initfn(PCIDevice *dev)
> {
> PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev);
> VGAState *s = &d->vga_state;
> @@ -2511,7 +2511,8 @@ static void pci_vga_initfn(PCIDevice *dev)
> bios_total_size <<= 1;
> pci_register_bar(&d->dev, PCI_ROM_SLOT, bios_total_size,
> PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map);
> - }
> + }
> + return 0;
> }
>
> int pci_vga_init(PCIBus *bus,
Looks like slight white-space damage, but isn't; the whole function is
indented weirdly.
[...]
Acked-by: Markus Armbruster <armbru@redhat.com>
next prev parent reply other threads:[~2009-08-12 17:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-12 15:59 [Qemu-devel] [PATCH] qdev: add return value to init() callbacks Gerd Hoffmann
2009-08-12 17:00 ` Markus Armbruster [this message]
2009-08-12 19:28 ` Paul Brook
2009-08-12 19:47 ` Gerd Hoffmann
2009-08-13 6:17 ` Markus Armbruster
2009-08-13 7:48 ` Gerd Hoffmann
2009-08-13 9:06 ` Markus Armbruster
2009-08-13 11:05 ` Gerd Hoffmann
2009-08-13 11:42 ` Markus Armbruster
2009-08-13 14:31 ` Gerd Hoffmann
2009-08-13 17:22 ` Markus Armbruster
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=87d4713r3a.fsf@pike.pond.sub.org \
--to=armbru@redhat.com \
--cc=kraxel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.