From patchwork Thu Dec 10 10:11:05 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 40793 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 29E3FB6F01 for ; Thu, 10 Dec 2009 21:14:19 +1100 (EST) Received: from localhost ([127.0.0.1]:41165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIg2K-0005xa-7e for incoming@patchwork.ozlabs.org; Thu, 10 Dec 2009 05:14:16 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIfzW-0005Bm-I5 for qemu-devel@nongnu.org; Thu, 10 Dec 2009 05:11:22 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIfzQ-00057o-R3 for qemu-devel@nongnu.org; Thu, 10 Dec 2009 05:11:21 -0500 Received: from [199.232.76.173] (port=49966 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIfzQ-00057g-Ly for qemu-devel@nongnu.org; Thu, 10 Dec 2009 05:11:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37166) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NIfzQ-0007nl-6f for qemu-devel@nongnu.org; Thu, 10 Dec 2009 05:11:16 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBAABFh5017999 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 10 Dec 2009 05:11:15 -0500 Received: from zweiblum.home.kraxel.org (vpn2-9-140.ams2.redhat.com [10.36.9.140]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBAABDhp030268; Thu, 10 Dec 2009 05:11:14 -0500 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id E5925700B9; Thu, 10 Dec 2009 11:11:11 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 10 Dec 2009 11:11:05 +0100 Message-Id: <1260439868-15061-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1260439868-15061-1-git-send-email-kraxel@redhat.com> References: <1260439868-15061-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [FOR 0.12 PATCH 1/4] pci: don't abort() when trying to hotplug with acpi off. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The PCI bus on x86 requires ACPI for hotplug support, thus disbling ACPI also disables hotplug for the PCI bus. This patch makes qemu check whenever the PCI bus in question can handle hotplug before trying to add devices. This is needed because qdev will abort() on any attempt to hotplug devices into a non-hotpluggable bus. Signed-off-by: Gerd Hoffmann --- hw/pci-hotplug.c | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index 081d6d1..7e5c51d 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -40,7 +40,18 @@ static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon, const char *opts_str) { QemuOpts *opts; - int ret; + PCIBus *bus; + int ret, devfn; + + bus = pci_get_bus_devfn(&devfn, devaddr); + if (!bus) { + monitor_printf(mon, "Invalid PCI device address %s\n", devaddr); + return NULL; + } + if (!((BusState*)bus)->allow_hotplug) { + monitor_printf(mon, "PCI bus doesn't support hotplug\n"); + return NULL; + } opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", NULL); if (!opts) { @@ -179,6 +190,10 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, monitor_printf(mon, "Invalid PCI device address %s\n", devaddr); return NULL; } + if (!((BusState*)bus)->allow_hotplug) { + monitor_printf(mon, "PCI bus doesn't support hotplug\n"); + return NULL; + } switch (type) { case IF_SCSI: