提交 081a12ab 编写于 作者: M Michal Privoznik

virpci: Introduce and use virPCIDeviceAddressGetIOMMUGroupDev

Sometimes, we have a PCI address and not fully allocated
virPCIDevice and yet we still want to know its /dev/vfio/N path.
Introduce virPCIDeviceAddressGetIOMMUGroupDev() function exactly
for that.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NCole Robinson <crobinso@redhat.com>
上级 cfce2980
...@@ -2709,6 +2709,7 @@ virPCIDeviceAddressAsString; ...@@ -2709,6 +2709,7 @@ virPCIDeviceAddressAsString;
virPCIDeviceAddressEqual; virPCIDeviceAddressEqual;
virPCIDeviceAddressFree; virPCIDeviceAddressFree;
virPCIDeviceAddressGetIOMMUGroupAddresses; virPCIDeviceAddressGetIOMMUGroupAddresses;
virPCIDeviceAddressGetIOMMUGroupDev;
virPCIDeviceAddressGetIOMMUGroupNum; virPCIDeviceAddressGetIOMMUGroupNum;
virPCIDeviceAddressGetSysfsFile; virPCIDeviceAddressGetSysfsFile;
virPCIDeviceAddressIOMMUGroupIterate; virPCIDeviceAddressIOMMUGroupIterate;
......
...@@ -13845,12 +13845,10 @@ qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev, ...@@ -13845,12 +13845,10 @@ qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev,
virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi; virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
virDomainHostdevSubsysSCSIVHostPtr hostsrc = &dev->source.subsys.u.scsi_host; virDomainHostdevSubsysSCSIVHostPtr hostsrc = &dev->source.subsys.u.scsi_host;
virDomainHostdevSubsysMediatedDevPtr mdevsrc = &dev->source.subsys.u.mdev; virDomainHostdevSubsysMediatedDevPtr mdevsrc = &dev->source.subsys.u.mdev;
g_autoptr(virPCIDevice) pci = NULL;
g_autoptr(virUSBDevice) usb = NULL; g_autoptr(virUSBDevice) usb = NULL;
g_autoptr(virSCSIDevice) scsi = NULL; g_autoptr(virSCSIDevice) scsi = NULL;
g_autoptr(virSCSIVHostDevice) host = NULL; g_autoptr(virSCSIVHostDevice) host = NULL;
g_autofree char *tmpPath = NULL; g_autofree char *tmpPath = NULL;
g_autofree int *tmpPerms = NULL;
int perm = 0; int perm = 0;
switch ((virDomainHostdevMode) dev->mode) { switch ((virDomainHostdevMode) dev->mode) {
...@@ -13858,14 +13856,7 @@ qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev, ...@@ -13858,14 +13856,7 @@ qemuDomainGetHostdevPath(virDomainHostdevDefPtr dev,
switch ((virDomainHostdevSubsysType)dev->source.subsys.type) { switch ((virDomainHostdevSubsysType)dev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
pci = virPCIDeviceNew(pcisrc->addr.domain, if (!(tmpPath = virPCIDeviceAddressGetIOMMUGroupDev(&pcisrc->addr)))
pcisrc->addr.bus,
pcisrc->addr.slot,
pcisrc->addr.function);
if (!pci)
return -1;
if (!(tmpPath = virPCIDeviceGetIOMMUGroupDev(pci)))
return -1; return -1;
perm = VIR_CGROUP_DEVICE_RW; perm = VIR_CGROUP_DEVICE_RW;
......
...@@ -1942,6 +1942,21 @@ virPCIDeviceAddressGetIOMMUGroupNum(virPCIDeviceAddressPtr addr) ...@@ -1942,6 +1942,21 @@ virPCIDeviceAddressGetIOMMUGroupNum(virPCIDeviceAddressPtr addr)
} }
char *
virPCIDeviceAddressGetIOMMUGroupDev(const virPCIDeviceAddress *devAddr)
{
g_autoptr(virPCIDevice) pci = NULL;
if (!(pci = virPCIDeviceNew(devAddr->domain,
devAddr->bus,
devAddr->slot,
devAddr->function)))
return NULL;
return virPCIDeviceGetIOMMUGroupDev(pci);
}
/* virPCIDeviceGetIOMMUGroupDev - return the name of the device used /* virPCIDeviceGetIOMMUGroupDev - return the name of the device used
* to control this PCI device's group (e.g. "/dev/vfio/15") * to control this PCI device's group (e.g. "/dev/vfio/15")
*/ */
......
...@@ -195,6 +195,7 @@ int virPCIDeviceAddressGetIOMMUGroupAddresses(virPCIDeviceAddressPtr devAddr, ...@@ -195,6 +195,7 @@ int virPCIDeviceAddressGetIOMMUGroupAddresses(virPCIDeviceAddressPtr devAddr,
virPCIDeviceAddressPtr **iommuGroupDevices, virPCIDeviceAddressPtr **iommuGroupDevices,
size_t *nIommuGroupDevices); size_t *nIommuGroupDevices);
int virPCIDeviceAddressGetIOMMUGroupNum(virPCIDeviceAddressPtr addr); int virPCIDeviceAddressGetIOMMUGroupNum(virPCIDeviceAddressPtr addr);
char *virPCIDeviceAddressGetIOMMUGroupDev(const virPCIDeviceAddress *devAddr);
char *virPCIDeviceGetIOMMUGroupDev(virPCIDevicePtr dev); char *virPCIDeviceGetIOMMUGroupDev(virPCIDevicePtr dev);
int virPCIDeviceIsAssignable(virPCIDevicePtr dev, int virPCIDeviceIsAssignable(virPCIDevicePtr dev,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册