mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-13 00:01:55 +00:00
conf: nodedev: Update PCI mdev capabilities dynamically
Just like SRIOV, a PCI device is only capable of the mediated devices framework when it's bound to the vendor native driver, thus if a driver change occurs, e.g. vendor_native->vfio, we need to refresh some of the device's capabilities to reflect the reality, mdev included. Signed-off-by: Erik Skultety <eskultet@redhat.com> Suggested-by: Wu Zongyong <cordius.wu@huawei.com> Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
882fd7a13c
commit
75dbb27b10
@ -2758,6 +2758,34 @@ virNodeDeviceGetPCIIOMMUGroupCaps(virNodeDevCapPCIDevPtr pci_dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
virNodeDeviceGetPCIMdevTypesCaps(const char *sysfspath,
|
||||||
|
virNodeDevCapPCIDevPtr pci_dev)
|
||||||
|
{
|
||||||
|
virMediatedDeviceTypePtr *types = NULL;
|
||||||
|
int rc = 0;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
/* this could be a refresh, so clear out the old data */
|
||||||
|
for (i = 0; i < pci_dev->nmdev_types; i++)
|
||||||
|
virMediatedDeviceTypeFree(pci_dev->mdev_types[i]);
|
||||||
|
VIR_FREE(pci_dev->mdev_types);
|
||||||
|
pci_dev->nmdev_types = 0;
|
||||||
|
pci_dev->flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_MDEV;
|
||||||
|
|
||||||
|
rc = virPCIGetMdevTypes(sysfspath, &types);
|
||||||
|
|
||||||
|
if (rc <= 0)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
VIR_STEAL_PTR(pci_dev->mdev_types, types);
|
||||||
|
pci_dev->nmdev_types = rc;
|
||||||
|
pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_MDEV;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* virNodeDeviceGetPCIDynamicCaps() get info that is stored in sysfs
|
/* virNodeDeviceGetPCIDynamicCaps() get info that is stored in sysfs
|
||||||
* about devices related to this device, i.e. things that can change
|
* about devices related to this device, i.e. things that can change
|
||||||
* without this device itself changing. These must be refreshed
|
* without this device itself changing. These must be refreshed
|
||||||
@ -2768,9 +2796,9 @@ int
|
|||||||
virNodeDeviceGetPCIDynamicCaps(const char *sysfsPath,
|
virNodeDeviceGetPCIDynamicCaps(const char *sysfsPath,
|
||||||
virNodeDevCapPCIDevPtr pci_dev)
|
virNodeDevCapPCIDevPtr pci_dev)
|
||||||
{
|
{
|
||||||
if (virNodeDeviceGetPCISRIOVCaps(sysfsPath, pci_dev) < 0)
|
if (virNodeDeviceGetPCISRIOVCaps(sysfsPath, pci_dev) < 0 ||
|
||||||
return -1;
|
virNodeDeviceGetPCIIOMMUGroupCaps(pci_dev) < 0 ||
|
||||||
if (virNodeDeviceGetPCIIOMMUGroupCaps(pci_dev) < 0)
|
virNodeDeviceGetPCIMdevTypesCaps(sysfsPath, pci_dev) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user