From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbKaD-0003fs-Pb for qemu-devel@nongnu.org; Thu, 26 Mar 2015 23:05:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YbKa8-0003pr-QL for qemu-devel@nongnu.org; Thu, 26 Mar 2015 23:05:17 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:34559) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbKa8-0003pc-L1 for qemu-devel@nongnu.org; Thu, 26 Mar 2015 23:05:12 -0400 Received: by pacwe9 with SMTP id we9so82030739pac.1 for ; Thu, 26 Mar 2015 20:05:11 -0700 (PDT) Message-ID: <5514C8DF.3040507@ozlabs.ru> Date: Fri, 27 Mar 2015 14:05:03 +1100 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <1427352132-1762-1-git-send-email-nikunj@linux.vnet.ibm.com> In-Reply-To: <1427352132-1762-1-git-send-email-nikunj@linux.vnet.ibm.com> Content-Type: text/plain; charset=koi8-r; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/2] vfio-pci: add flag to identify vfio pci device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikunj A Dadhania , qemu-devel@nongnu.org Cc: Alex Williamson , qemu-ppc@nongnu.org, agraf@suse.de, david@gibson.dropbear.id.au On 03/26/2015 05:42 PM, Nikunj A Dadhania wrote: > From PCIDevice there is no way to know if the device has a backing > vfio device. > > sPAPR guests inherits the "ibm,loc-code" from the pci pass through > device in hypervisor. This helps in identifying the device if there is > any failures using this "ibm,loc-code" for RAS capabilities. First, you can use object_dynamic_cast(OBJECT(obj), "vfio-pci") to know if it is a VFIO device. Second, rather than adding this flag here, I would fix the second patch to check if PHB is of the TYPE_SPAPR_PCI_VFIO_HOST_BRIDGE type ("spapr-pci-vfio-host-bridge"), using the same QOM mechanism. > CC: Alex Williamson > CC: Alexander Graf > Signed-off-by: Nikunj A Dadhania > --- > hw/vfio/pci.c | 2 ++ > include/hw/pci/pci.h | 2 ++ > 2 files changed, 4 insertions(+) > > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c > index 6b80539..95d666e 100644 > --- a/hw/vfio/pci.c > +++ b/hw/vfio/pci.c > @@ -3483,6 +3483,7 @@ static void vfio_instance_finalize(Object *obj) > VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pci_dev); > VFIOGroup *group = vdev->vbasedev.group; > > + pci_dev->is_vfio = false; > vfio_unmap_bars(vdev); > g_free(vdev->emulated_config_bits); > g_free(vdev->rom); > @@ -3542,6 +3543,7 @@ static void vfio_instance_init(Object *obj) > PCIDevice *pci_dev = PCI_DEVICE(obj); > VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, PCI_DEVICE(obj)); > > + pci_dev->is_vfio = true; > device_add_bootindex_property(obj, &vdev->bootindex, > "bootindex", NULL, > &pci_dev->qdev, NULL); > diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h > index b97c295..0ddc830 100644 > --- a/include/hw/pci/pci.h > +++ b/include/hw/pci/pci.h > @@ -291,6 +291,8 @@ struct PCIDevice { > /* SHPC */ > SHPCDevice *shpc; > > + bool is_vfio; > + > /* Location of option rom */ > char *romfile; > bool has_rom; > -- Alexey