The patch implements sPAPRPHBClass::format_errinjct_cmd to do the address translation (BUID+PE number to IOMMU group ID) and then come up with the formatted string for PCI error injection.
Signed-off-by: Gavin Shan <gws...@linux.vnet.ibm.com> --- hw/ppc/spapr_pci_vfio.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c index 0a1e902..1f9f0bf 100644 --- a/hw/ppc/spapr_pci_vfio.c +++ b/hw/ppc/spapr_pci_vfio.c @@ -227,6 +227,24 @@ static int spapr_phb_vfio_eeh_handler(sPAPRPHBState *sphb, int req, int opt) VFIO_EEH_PE_OP, &op); } +static char *format_errinjct_cmd(sPAPRPHBState *sphb, sPAPRErrInjctIOA *ioa) +{ + sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb); + char *pstr = NULL; + + /* Invalid IOMMU group ID ? */ + if (svphb->iommugroupid == -1) { + goto out; + } + + /* Formatted string */ + pstr = g_strdup_printf("%x:%lx:%lx:%x:%x", + ioa->ei_token, ioa->addr, ioa->mask, + svphb->iommugroupid, ioa->func); +out: + return pstr; +} + static void spapr_phb_vfio_reset(DeviceState *qdev) { /* Do nothing */ @@ -241,6 +259,7 @@ static void spapr_phb_vfio_class_init(ObjectClass *klass, void *data) dc->reset = spapr_phb_vfio_reset; spc->finish_realize = spapr_phb_vfio_finish_realize; spc->eeh_handler = spapr_phb_vfio_eeh_handler; + spc->format_errinjct_cmd = format_errinjct_cmd; } static const TypeInfo spapr_phb_vfio_info = { -- 1.8.3.2