qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [FOR 0.12 PATCH 2/4] pci: don't hw_error() when no slot is available.
Date: Thu, 10 Dec 2009 14:08:06 +0200	[thread overview]
Message-ID: <20091210120806.GB13657@redhat.com> (raw)
In-Reply-To: <1260439868-15061-3-git-send-email-kraxel@redhat.com>

On Thu, Dec 10, 2009 at 11:11:06AM +0100, Gerd Hoffmann wrote:
> Current PCI code will simply hw_error() and thus abort in case no free
> PCI slot is available or the requested PCI slot is already in use by
> another device.  For the hotplug case this behavior is not acceptable.
> This patch makes qemu pass up the error properly, so the calling code
> can decide whenever it wants to exit with an error (on startup) or
> whenever it wants to continue (hotplug).
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>


Good stuff. However

> ---
>  hw/pci.c |   11 +++++++++--
>  1 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index 4f662b7..404eead 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -580,11 +580,13 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>              if (!bus->devices[devfn])
>                  goto found;
>          }
> -        hw_error("PCI: no devfn available for %s, all in use\n", name);
> +        qemu_error("PCI: no devfn available for %s, all in use\n", name);
> +        return NULL;
>      found: ;
>      } else if (bus->devices[devfn]) {
> -        hw_error("PCI: devfn %d not available for %s, in use by %s\n", devfn,
> +        qemu_error("PCI: devfn %d not available for %s, in use by %s\n", devfn,
>                   name, bus->devices[devfn]->name);
> +        return NULL;
>      }
>      pci_dev->bus = bus;
>      pci_dev->devfn = devfn;
> @@ -625,6 +627,9 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name,
>      pci_dev = do_pci_register_device(pci_dev, bus, name, devfn,
>                                       config_read, config_write,
>                                       PCI_HEADER_TYPE_NORMAL);
> +    if (pci_dev == NULL) {
> +        hw_error("PCI: can't register device\n");
> +    }

Can you please use !pci_dev for these checks?

>      return pci_dev;
>  }
>  static target_phys_addr_t pci_to_cpu_addr(target_phys_addr_t addr)
> @@ -1376,6 +1381,8 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
>      pci_dev = do_pci_register_device(pci_dev, bus, base->name, devfn,
>                                       info->config_read, info->config_write,
>                                       info->header_type);
> +    if (pci_dev == NULL)
> +        return -1;

And here too.

>      rc = info->init(pci_dev);
>      if (rc != 0)
>          return rc;
> -- 
> 1.6.5.2
> 
> 

  reply	other threads:[~2009-12-10 12:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-10 10:11 [Qemu-devel] [FOR 0.12 PATCH 0/4] misc bugfixes Gerd Hoffmann
2009-12-10 10:11 ` [Qemu-devel] [FOR 0.12 PATCH 1/4] pci: don't abort() when trying to hotplug with acpi off Gerd Hoffmann
2009-12-10 10:11 ` [Qemu-devel] [FOR 0.12 PATCH 2/4] pci: don't hw_error() when no slot is available Gerd Hoffmann
2009-12-10 12:08   ` Michael S. Tsirkin [this message]
2009-12-10 12:19     ` [Qemu-devel] " Gerd Hoffmann
2009-12-10 12:23       ` Michael S. Tsirkin
2009-12-10 13:22         ` Gleb Natapov
2009-12-10 18:04           ` Michael S. Tsirkin
2009-12-10 19:13             ` Gleb Natapov
2009-12-11 10:37               ` Michael S. Tsirkin
2009-12-11 11:03                 ` Gleb Natapov
2009-12-10 12:33     ` Alexander Graf
2009-12-10 10:11 ` [Qemu-devel] [FOR 0.12 PATCH 3/4] scsi: fix drive hotplug Gerd Hoffmann
2009-12-10 10:11 ` [Qemu-devel] [FOR 0.12 PATCH 4/4] QemuOpts: allow larger option values Gerd Hoffmann
2009-12-10 12:03 ` [Qemu-devel] Re: [FOR 0.12 PATCH 0/4] misc bugfixes Michael S. Tsirkin
2009-12-10 12:15   ` Gerd Hoffmann
2009-12-10 15:37   ` Anthony Liguori

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=20091210120806.GB13657@redhat.com \
    --to=mst@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 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).