From patchwork Tue Sep 2 08:04:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 385013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8DA4B140119 for ; Tue, 2 Sep 2014 18:11:19 +1000 (EST) Received: from localhost ([::1]:36495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOjBN-0005nb-D5 for incoming@patchwork.ozlabs.org; Tue, 02 Sep 2014 04:11:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOj6D-0005vx-DS for qemu-devel@nongnu.org; Tue, 02 Sep 2014 04:06:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XOj68-0006MF-2s for qemu-devel@nongnu.org; Tue, 02 Sep 2014 04:05:57 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:52148) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOj67-0006Le-BW for qemu-devel@nongnu.org; Tue, 02 Sep 2014 04:05:52 -0400 Received: from 172.24.2.119 (EHLO szxeml450-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BYY10708; Tue, 02 Sep 2014 16:05:35 +0800 (CST) Received: from localhost (10.177.19.102) by szxeml450-hub.china.huawei.com (10.82.67.193) with Microsoft SMTP Server id 14.3.158.1; Tue, 2 Sep 2014 16:04:36 +0800 From: To: Date: Tue, 2 Sep 2014 16:04:30 +0800 Message-ID: <1409645070-8720-5-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 1.7.3.1.msysgit.0 In-Reply-To: <1409645070-8720-1-git-send-email-arei.gonglei@huawei.com> References: <1409645070-8720-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.102] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Cc: peter.crosthwaite@xilinx.com, weidong.huang@huawei.com, mst@redhat.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, Gonglei , imammedo@redhat.com, pbonzini@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v4 4/4] pcie: don't assert when hotplug a PCIe device with 'function != 0' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Gonglei It's enough to report 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 1babddf..ab7f8a2 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; + } pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA, PCI_EXP_SLTSTA_PDS);