From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XghZZ-0005gg-SA for qemu-devel@nongnu.org; Tue, 21 Oct 2014 18:06:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XghZQ-0000WN-Q7 for qemu-devel@nongnu.org; Tue, 21 Oct 2014 18:06:33 -0400 Received: from mail-wg0-x22d.google.com ([2a00:1450:400c:c00::22d]:51397) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XghZQ-0000WI-JH for qemu-devel@nongnu.org; Tue, 21 Oct 2014 18:06:24 -0400 Received: by mail-wg0-f45.google.com with SMTP id m15so2373756wgh.4 for ; Tue, 21 Oct 2014 15:06:23 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <5446D8DA.6000003@redhat.com> Date: Wed, 22 Oct 2014 00:06:18 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1413895032-10116-1-git-send-email-marcel.a@redhat.com> In-Reply-To: <1413895032-10116-1-git-send-email-marcel.a@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] hw/pci: fixed crash when using rombar=0 for hotplugged devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcel Apfelbaum , qemu-devel@nongnu.org Cc: mst@redhat.com On 10/21/2014 02:37 PM, Marcel Apfelbaum wrote: > ROM images must be loaded at startup. Usage of rombar=0 after that > is not allowed, but should not crash QEMU. > > Check that the device is not hotplugged before trying to > insert the rom file. I think it could also make sense to just ignore the option ROM and allow the hotplug. Sooner or later we should drop the oldest compat machine types... everything until 0.12 probably could go. Paolo > Signed-off-by: Marcel Apfelbaum > --- > hw/pci/pci.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > index 6ce75aa..3907c90 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; > } > @@ -1940,6 +1945,10 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom) > if (class == 0x0300) { > rom_add_vga(pdev->romfile); > } else { > + if (DEVICE(pdev)->hotplugged) { > + error_report("PCI: rombar can't be 0 for hotplugged devices!"); > + return -1; > + } > rom_add_option(pdev->romfile, -1); > } > return 0; >