From: "Michael S. Tsirkin" <mst@redhat.com>
To: Marcel Apfelbaum <marcel.a@redhat.com>
Cc: pbonzini@redhat.com, alex.williamson@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] hw/pci: fixed crash when using rombar=0 with romfile=path for hotplugged devices
Date: Mon, 27 Oct 2014 16:52:33 +0200 [thread overview]
Message-ID: <20141027145233.GA20023@redhat.com> (raw)
In-Reply-To: <1414417444-32158-1-git-send-email-marcel.a@redhat.com>
On Mon, Oct 27, 2014 at 03:44:04PM +0200, Marcel Apfelbaum wrote:
> Combining rombar=0 with romfile=<path> is an user error,
> silently dropping the romfile is a reasonable thing to do.
>
> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
How about failing adding the device instead?
Return error from pci_add_option_rom, and check at
calling sites?
> ---
> v1 -> v2:
> After a discussion with Michael, Paolo and Alex, this
> patch silent drops the romfile instead of not allowing
> the hotplug.
>
> An OK from libvirt will be nice.
>
> hw/pci/pci.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 6ce75aa..cd7a403 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -1776,7 +1776,12 @@ static int pci_qdev_init(DeviceState *qdev)
> pci_dev->romfile = g_strdup(pc->romfile);
> is_default_rom = true;
> }
> - pci_add_option_rom(pci_dev, is_default_rom);
> +
> + rc = pci_add_option_rom(pci_dev, is_default_rom);
> + if (rc != 0) {
> + pci_unregister_device(DEVICE(pci_dev));
> + return rc;
> + }
>
> return 0;
> }
> @@ -1937,6 +1942,15 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
> * for 0.11 compatibility.
> */
> int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
> +
> + /*
> + * For hot-plugged devices silently ignore the option ROM
> + * if the rom bar is disabled.
> + */
> + if (DEVICE(pdev)->hotplugged) {
> + return 0;
> + }
> +
> if (class == 0x0300) {
> rom_add_vga(pdev->romfile);
> } else {
> --
> 1.8.3.1
next prev parent reply other threads:[~2014-10-27 14:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-27 13:44 [Qemu-devel] [PATCH v2] hw/pci: fixed crash when using rombar=0 with romfile=path for hotplugged devices Marcel Apfelbaum
2014-10-27 13:50 ` Marcel Apfelbaum
2014-10-27 14:52 ` Michael S. Tsirkin [this message]
2014-10-27 15:04 ` Marcel Apfelbaum
2014-10-27 16:03 ` Michael S. Tsirkin
2014-10-27 17:06 ` Eric Blake
2014-10-27 14:59 ` Markus Armbruster
2014-10-27 15:04 ` Marcel Apfelbaum
2014-10-27 15:54 ` 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=20141027145233.GA20023@redhat.com \
--to=mst@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=marcel.a@redhat.com \
--cc=pbonzini@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.