qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH 03/14] spapr_pci: Expose and generalize spapr_ph


From: David Gibson
Subject: [Qemu-devel] [RFC PATCH 03/14] spapr_pci: Expose and generalize spapr_phb_check_vfio_group()
Date: Sat, 19 Sep 2015 17:18:26 +1000

At the moment spapr_phb_check_vfio_group() assumes it is always passed an
instance of "spapr-pci-vfio-host-bridge", which it is.  However we want to
unify more of the code with core PAPR PCI, so this changes it to be safe on
any "spapr-pci-host-bridge" instance.  For now we just return an error if
it's not a VFIO host bridge.  We also expose the function, because we'll
be needing it elsewhere.

Signed-off-by: David Gibson <address@hidden>
---
 hw/ppc/spapr_pci_vfio.c     | 6 +++++-
 include/hw/pci-host/spapr.h | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c
index a2b1093..047fb30 100644
--- a/hw/ppc/spapr_pci_vfio.c
+++ b/hw/ppc/spapr_pci_vfio.c
@@ -31,10 +31,14 @@ static Property spapr_phb_vfio_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
-static int spapr_phb_check_vfio_group(sPAPRPHBState *phb, VFIOGroup **gpp)
+int spapr_phb_check_vfio_group(sPAPRPHBState *phb, VFIOGroup **gpp)
 {
     VFIOGroup *group;
 
+    if (!object_dynamic_cast(OBJECT(phb), "spapr-pci-vfio-host-bridge")) {
+        return RTAS_OUT_PARAM_ERROR;
+    }
+
     /* FIXME: this is an abstraction violation */
     group = vfio_get_group(SPAPR_PCI_VFIO_HOST_BRIDGE(phb)->iommugroupid,
                            &phb->iommu_as);
diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h
index 7de5e02..68cf99b 100644
--- a/include/hw/pci-host/spapr.h
+++ b/include/hw/pci-host/spapr.h
@@ -26,6 +26,7 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_host.h"
 #include "hw/ppc/xics.h"
+#include "hw/vfio/vfio-eeh.h"
 
 #define TYPE_SPAPR_PCI_HOST_BRIDGE "spapr-pci-host-bridge"
 #define TYPE_SPAPR_PCI_VFIO_HOST_BRIDGE "spapr-pci-vfio-host-bridge"
@@ -133,6 +134,7 @@ void spapr_pci_msi_init(sPAPRMachineState *spapr, hwaddr 
addr);
 
 void spapr_pci_rtas_init(void);
 
+int spapr_phb_check_vfio_group(sPAPRPHBState *phb, VFIOGroup **gpp);
 sPAPRPHBState *spapr_pci_find_phb(sPAPRMachineState *spapr, uint64_t buid);
 PCIDevice *spapr_pci_find_dev(sPAPRMachineState *spapr, uint64_t buid,
                               uint32_t config_addr);
-- 
2.4.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]