From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ximlc-00022E-EG for qemu-devel@nongnu.org; Mon, 27 Oct 2014 12:03:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XimlW-0004VI-9J for qemu-devel@nongnu.org; Mon, 27 Oct 2014 12:03:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33093) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XimlW-0004V3-2x for qemu-devel@nongnu.org; Mon, 27 Oct 2014 12:03:30 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9RG3Rq2016945 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 27 Oct 2014 12:03:28 -0400 Date: Mon, 27 Oct 2014 18:03:24 +0200 From: "Michael S. Tsirkin" Message-ID: <20141027160324.GC17923@redhat.com> References: <1414417444-32158-1-git-send-email-marcel.a@redhat.com> <20141027145233.GA20023@redhat.com> <1414422243.29756.56.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1414422243.29756.56.camel@localhost.localdomain> Subject: Re: [Qemu-devel] [PATCH v2] hw/pci: fixed crash when using rombar=0 with romfile=path for hotplugged devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcel Apfelbaum Cc: pbonzini@redhat.com, alex.williamson@redhat.com, qemu-devel@nongnu.org On Mon, Oct 27, 2014 at 05:04:03PM +0200, Marcel Apfelbaum wrote: > On Mon, 2014-10-27 at 16:52 +0200, Michael S. Tsirkin wrote: > > On Mon, Oct 27, 2014 at 03:44:04PM +0200, Marcel Apfelbaum wrote: > > > Combining rombar=0 with romfile= is an user error, > > > silently dropping the romfile is a reasonable thing to do. > > > > > > Signed-off-by: Marcel Apfelbaum > > > > How about failing adding the device instead? > > Return error from pci_add_option_rom, and check at > > calling sites? > > This was was the prev version of this patch has done, > we have only one calling site: pci_qdev_init. > I could tweak the prev version to return error on both > rom_add_vga/rom_add_option, but I was under the impression > that silently drop the romfile was discussion's decision. > > I am fine both ways, as it is a user error and hopefully > used correctly by libvirt. I only want to avoid the crash. > > Thanks, > Marcel Let's try the non silent error. If someone is unhappy we can make it silent again, but if it succeeds we'll have to keep it working forever. > > > --- > > > 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 > >