From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJqzj-0004xm-MQ for qemu-devel@nongnu.org; Tue, 19 Aug 2014 17:31:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJqze-0004qx-T2 for qemu-devel@nongnu.org; Tue, 19 Aug 2014 17:31:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJqze-0004qe-Kj for qemu-devel@nongnu.org; Tue, 19 Aug 2014 17:31:02 -0400 Date: Tue, 19 Aug 2014 23:31:29 +0200 From: "Michael S. Tsirkin" Message-ID: <20140819213129.GA10908@redhat.com> References: <1408441305-11044-1-git-send-email-arei.gonglei@huawei.com> <1408441305-11044-4-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1408441305-11044-4-git-send-email-arei.gonglei@huawei.com> Subject: Re: [Qemu-devel] [PATCH 3/3] pcie: using error_setg instead of impolite assert List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com Cc: peter.crosthwaite@xilinx.com, weidong.huang@huawei.com, qemu-devel@nongnu.org, peter.huangpeng@huawei.com, imammedo@redhat.com, pbonzini@redhat.com, afaerber@suse.de On Tue, Aug 19, 2014 at 05:41:45PM +0800, arei.gonglei@huawei.com wrote: > From: Gonglei > > It's enough of reporting an error. Assert() is not acceptable > because the error is not a fatal error. > > Signed-off-by: Gonglei > --- > hw/pci/pcie.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c > index a123c01..7b46140 100644 > --- a/hw/pci/pcie.c > +++ b/hw/pci/pcie.c > @@ -254,7 +254,11 @@ void pcie_cap_slot_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, > * Right now, only a device of function = 0 is allowed to be > * hot plugged/unplugged. > */ > - assert(PCI_FUNC(pci_dev->devfn) == 0); > + if (PCI_FUNC(pci_dev->devfn) != 0) { > + error_setg(errp, "Unsupported device function %d for PCIe hotplugging, " > + "only supported function 0", PCI_FUNC(pci_dev->devfn)); > + return; > + } Unplug of multifunction devices really should work. Drop this assert and see what happens. For hot-plug we don't have good APIs yet but we really should define them rather than add more code that we have to later remove. > pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA, > PCI_EXP_SLTSTA_PDS); > -- > 1.7.12.4 >