From patchwork Wed Jul 1 16:22:27 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 33512 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n61GMXJK007198 for ; Wed, 1 Jul 2009 16:22:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752295AbZGAQW1 (ORCPT ); Wed, 1 Jul 2009 12:22:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752633AbZGAQW1 (ORCPT ); Wed, 1 Jul 2009 12:22:27 -0400 Received: from mx2.redhat.com ([66.187.237.31]:34556 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752254AbZGAQW0 (ORCPT ); Wed, 1 Jul 2009 12:22:26 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n61GMUlf025140 for ; Wed, 1 Jul 2009 12:22:30 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n61GMT0P017224 for ; Wed, 1 Jul 2009 12:22:29 -0400 Received: from pike.pond.sub.org (vpn-10-2.str.redhat.com [10.32.10.2]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n61GMSCu030100 for ; Wed, 1 Jul 2009 12:22:28 -0400 Received: by pike.pond.sub.org (Postfix, from userid 1000) id CCB3310083; Wed, 1 Jul 2009 18:22:27 +0200 (CEST) To: kvm-devel Subject: [PATCH] Fix up device assignment hotplug and re-enable it References: <4A43B2B3.1040204@redhat.com> From: Markus Armbruster Date: Wed, 01 Jul 2009 18:22:27 +0200 In-Reply-To: <4A43B2B3.1040204@redhat.com> (Avi Kivity's message of "Thu\, 25 Jun 2009 20\:24\:03 +0300") Message-ID: <87ws6sqsos.fsf@pike.pond.sub.org> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Disabled in merge commit a3b371477e3. Signed-off-by: Markus Armbruster --- hw/device-assignment.c | 11 +++++------ hw/pci.c | 2 +- hw/pci.h | 1 + 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index e282498..88c3baf 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -1126,9 +1126,8 @@ static int assigned_dev_register_msix_mmio(AssignedDevice *dev) struct PCIDevice *init_assigned_device(AssignedDevInfo *adev, const char *devaddr) { - printf("init_assigned_device: fix me please\n"); - return NULL; -#if 0 + PCIBus *bus; + int devfn; int r; AssignedDevice *dev; PCIDevice *pci_dev; @@ -1138,8 +1137,9 @@ struct PCIDevice *init_assigned_device(AssignedDevInfo *adev, DEBUG("Registering real physical device %s (bus=%x dev=%x func=%x)\n", adev->name, adev->bus, adev->dev, adev->func); + bus = pci_get_bus_devfn(&devfn, devaddr); pci_dev = pci_register_device(bus, adev->name, - sizeof(AssignedDevice), -1, assigned_dev_pci_read_config, + sizeof(AssignedDevice), devfn, assigned_dev_pci_read_config, assigned_dev_pci_write_config); dev = container_of(pci_dev, AssignedDevice, dev); @@ -1203,7 +1203,6 @@ assigned_out: out: free_assigned_device(adev); return NULL; -#endif } /* @@ -1268,7 +1267,7 @@ void add_assigned_devices(PCIBus *bus, const char **devices, int n_devices) exit(1); } - if (!init_assigned_device(adev, bus)) { + if (!init_assigned_device(adev, NULL)) { fprintf(stderr, "Failed to initialize assigned device %s\n", devices[i]); exit(1); diff --git a/hw/pci.c b/hw/pci.c index 618582a..0107096 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -290,7 +290,7 @@ int pci_read_devaddr(const char *addr, int *domp, int *busp, unsigned *slotp) return pci_parse_devaddr(devaddr, domp, busp, slotp); } -static PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr) +PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr) { int dom, bus; unsigned slot; diff --git a/hw/pci.h b/hw/pci.h index 7d8df83..a2c3a23 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -239,6 +239,7 @@ int pci_read_devaddr(const char *addr, int *domp, int *busp, unsigned *slotp); int pci_parse_host_devaddr(const char *addr, int *busp, int *slotp, int *funcp); +PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr); void pci_info(Monitor *mon); PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid, uint16_t did,