mirror of https://gitee.com/openkylin/libvirt.git
virpci.c: simplify virPCIDeviceNew() signature
The current virPCIDeviceNew() signature, receiving 4 uints in sequence (domain, bus, slot, function), is not neat. We already have a way to represent a PCI address in virPCIDeviceAddress that is used in the code. Aside from the test files, most of virPCIDeviceNew() callers have access to a virPCIDeviceAddress reference, but then we need to retrieve the 4 required uints (addr.domain, addr.bus, addr.slot, addr.function) to satisfy virPCIDeviceNew(). The result is that we have extra verbosity/boilerplate to retrieve an information that is already available in virPCIDeviceAddress. A better way is presented by virNVMEDeviceNew(), where the caller just supplies a virPCIDeviceAddress pointer and the function handles the details internally. This patch changes virPCIDeviceNew() to receive a virPCIDeviceAddress pointer instead of 4 uints. Reviewed-by: Laine Stump <laine@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
0e0c974b20
commit
b0264e9404
|
@ -235,8 +235,7 @@ virHostdevGetPCIHostDevice(const virDomainHostdevDef *hostdev,
|
||||||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
actual = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus,
|
actual = virPCIDeviceNew(&pcisrc->addr);
|
||||||
pcisrc->addr.slot, pcisrc->addr.function);
|
|
||||||
|
|
||||||
if (!actual)
|
if (!actual)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -5818,7 +5818,7 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
||||||
if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
|
if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
pci = virPCIDeviceNew(devAddr.domain, devAddr.bus, devAddr.slot, devAddr.function);
|
pci = virPCIDeviceNew(&devAddr);
|
||||||
if (!pci)
|
if (!pci)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -5889,7 +5889,7 @@ libxlNodeDeviceReAttach(virNodeDevicePtr dev)
|
||||||
if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
|
if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
pci = virPCIDeviceNew(devAddr.domain, devAddr.bus, devAddr.slot, devAddr.function);
|
pci = virPCIDeviceNew(&devAddr);
|
||||||
if (!pci)
|
if (!pci)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -5947,7 +5947,7 @@ libxlNodeDeviceReset(virNodeDevicePtr dev)
|
||||||
if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
|
if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
pci = virPCIDeviceNew(devAddr.domain, devAddr.bus, devAddr.slot, devAddr.function);
|
pci = virPCIDeviceNew(&devAddr);
|
||||||
if (!pci)
|
if (!pci)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
|
|
@ -367,6 +367,7 @@ udevProcessPCI(struct udev_device *device,
|
||||||
virNodeDevCapPCIDevPtr pci_dev = &def->caps->data.pci_dev;
|
virNodeDevCapPCIDevPtr pci_dev = &def->caps->data.pci_dev;
|
||||||
virPCIEDeviceInfoPtr pci_express = NULL;
|
virPCIEDeviceInfoPtr pci_express = NULL;
|
||||||
virPCIDevicePtr pciDev = NULL;
|
virPCIDevicePtr pciDev = NULL;
|
||||||
|
virPCIDeviceAddress devAddr;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *p;
|
char *p;
|
||||||
bool privileged;
|
bool privileged;
|
||||||
|
@ -416,10 +417,12 @@ udevProcessPCI(struct udev_device *device,
|
||||||
if (virNodeDeviceGetPCIDynamicCaps(def->sysfs_path, pci_dev) < 0)
|
if (virNodeDeviceGetPCIDynamicCaps(def->sysfs_path, pci_dev) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(pciDev = virPCIDeviceNew(pci_dev->domain,
|
devAddr.domain = pci_dev->domain;
|
||||||
pci_dev->bus,
|
devAddr.bus = pci_dev->bus;
|
||||||
pci_dev->slot,
|
devAddr.slot = pci_dev->slot;
|
||||||
pci_dev->function)))
|
devAddr.function = pci_dev->function;
|
||||||
|
|
||||||
|
if (!(pciDev = virPCIDeviceNew(&devAddr)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* We need to be root to read PCI device configs */
|
/* We need to be root to read PCI device configs */
|
||||||
|
|
|
@ -863,10 +863,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(pciDev = virPCIDeviceNew(hostAddr->domain,
|
if (!(pciDev = virPCIDeviceNew(hostAddr))) {
|
||||||
hostAddr->bus,
|
|
||||||
hostAddr->slot,
|
|
||||||
hostAddr->function))) {
|
|
||||||
/* libvirt should be able to perform all the
|
/* libvirt should be able to perform all the
|
||||||
* operations in virPCIDeviceNew() even if it's
|
* operations in virPCIDeviceNew() even if it's
|
||||||
* running unprivileged, so if this fails, the device
|
* running unprivileged, so if this fails, the device
|
||||||
|
|
|
@ -12009,7 +12009,7 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
||||||
if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
|
if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
pci = virPCIDeviceNew(devAddr.domain, devAddr.bus, devAddr.slot, devAddr.function);
|
pci = virPCIDeviceNew(&devAddr);
|
||||||
if (!pci)
|
if (!pci)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -12090,7 +12090,7 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev)
|
||||||
if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
|
if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
pci = virPCIDeviceNew(devAddr.domain, devAddr.bus, devAddr.slot, devAddr.function);
|
pci = virPCIDeviceNew(&devAddr);
|
||||||
if (!pci)
|
if (!pci)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -12144,7 +12144,7 @@ qemuNodeDeviceReset(virNodeDevicePtr dev)
|
||||||
if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
|
if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
pci = virPCIDeviceNew(devAddr.domain, devAddr.bus, devAddr.slot, devAddr.function);
|
pci = virPCIDeviceNew(&devAddr);
|
||||||
if (!pci)
|
if (!pci)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
|
|
@ -892,8 +892,7 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
|
||||||
|
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
||||||
virPCIDevicePtr pci =
|
virPCIDevicePtr pci =
|
||||||
virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus,
|
virPCIDeviceNew(&pcisrc->addr);
|
||||||
pcisrc->addr.slot, pcisrc->addr.function);
|
|
||||||
|
|
||||||
if (!pci)
|
if (!pci)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
@ -1268,8 +1268,7 @@ virSecurityDACSetHostdevLabel(virSecurityManagerPtr mgr,
|
||||||
|
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
||||||
virPCIDevicePtr pci =
|
virPCIDevicePtr pci =
|
||||||
virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus,
|
virPCIDeviceNew(&pcisrc->addr);
|
||||||
pcisrc->addr.slot, pcisrc->addr.function);
|
|
||||||
|
|
||||||
if (!pci)
|
if (!pci)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1437,8 +1436,7 @@ virSecurityDACRestoreHostdevLabel(virSecurityManagerPtr mgr,
|
||||||
|
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
||||||
virPCIDevicePtr pci =
|
virPCIDevicePtr pci =
|
||||||
virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus,
|
virPCIDeviceNew(&pcisrc->addr);
|
||||||
pcisrc->addr.slot, pcisrc->addr.function);
|
|
||||||
|
|
||||||
if (!pci)
|
if (!pci)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -2105,8 +2105,7 @@ virSecuritySELinuxSetHostdevSubsysLabel(virSecurityManagerPtr mgr,
|
||||||
|
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
||||||
virPCIDevicePtr pci =
|
virPCIDevicePtr pci =
|
||||||
virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus,
|
virPCIDeviceNew(&pcisrc->addr);
|
||||||
pcisrc->addr.slot, pcisrc->addr.function);
|
|
||||||
|
|
||||||
if (!pci)
|
if (!pci)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -2345,8 +2344,7 @@ virSecuritySELinuxRestoreHostdevSubsysLabel(virSecurityManagerPtr mgr,
|
||||||
|
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
||||||
virPCIDevicePtr pci =
|
virPCIDevicePtr pci =
|
||||||
virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus,
|
virPCIDeviceNew(&pcisrc->addr);
|
||||||
pcisrc->addr.slot, pcisrc->addr.function);
|
|
||||||
|
|
||||||
if (!pci)
|
if (!pci)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -1105,11 +1105,7 @@ get_files(vahControl * ctl)
|
||||||
}
|
}
|
||||||
|
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
||||||
virPCIDevicePtr pci = virPCIDeviceNew(
|
virPCIDevicePtr pci = virPCIDeviceNew(&dev->source.subsys.u.pci.addr);
|
||||||
dev->source.subsys.u.pci.addr.domain,
|
|
||||||
dev->source.subsys.u.pci.addr.bus,
|
|
||||||
dev->source.subsys.u.pci.addr.slot,
|
|
||||||
dev->source.subsys.u.pci.addr.function);
|
|
||||||
|
|
||||||
virDomainHostdevSubsysPCIBackendType backend = dev->source.subsys.u.pci.backend;
|
virDomainHostdevSubsysPCIBackendType backend = dev->source.subsys.u.pci.backend;
|
||||||
if (backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO ||
|
if (backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO ||
|
||||||
|
|
|
@ -1141,8 +1141,7 @@ virNetDevGetPCIDevice(const char *devName)
|
||||||
if (!vfPCIAddr)
|
if (!vfPCIAddr)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return virPCIDeviceNew(vfPCIAddr->domain, vfPCIAddr->bus,
|
return virPCIDeviceNew(vfPCIAddr);
|
||||||
vfPCIAddr->slot, vfPCIAddr->function);
|
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|
|
@ -290,10 +290,7 @@ virNVMeDeviceCreatePCIDevice(const virNVMeDevice *nvme)
|
||||||
{
|
{
|
||||||
g_autoptr(virPCIDevice) pci = NULL;
|
g_autoptr(virPCIDevice) pci = NULL;
|
||||||
|
|
||||||
if (!(pci = virPCIDeviceNew(nvme->address.domain,
|
if (!(pci = virPCIDeviceNew(&nvme->address)))
|
||||||
nvme->address.bus,
|
|
||||||
nvme->address.slot,
|
|
||||||
nvme->address.function)))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* NVMe devices must be bound to vfio */
|
/* NVMe devices must be bound to vfio */
|
||||||
|
|
|
@ -475,24 +475,24 @@ virPCIDeviceIterDevices(virPCIDeviceIterPredicate predicate,
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while ((ret = virDirRead(dir, &entry, PCI_SYSFS "devices")) > 0) {
|
while ((ret = virDirRead(dir, &entry, PCI_SYSFS "devices")) > 0) {
|
||||||
unsigned int domain, bus, slot, function;
|
|
||||||
g_autoptr(virPCIDevice) check = NULL;
|
g_autoptr(virPCIDevice) check = NULL;
|
||||||
|
virPCIDeviceAddress devAddr;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
/* expected format: <domain>:<bus>:<slot>.<function> */
|
/* expected format: <domain>:<bus>:<slot>.<function> */
|
||||||
if (/* domain */
|
if (/* domain */
|
||||||
virStrToLong_ui(entry->d_name, &tmp, 16, &domain) < 0 || *tmp != ':' ||
|
virStrToLong_ui(entry->d_name, &tmp, 16, &devAddr.domain) < 0 || *tmp != ':' ||
|
||||||
/* bus */
|
/* bus */
|
||||||
virStrToLong_ui(tmp + 1, &tmp, 16, &bus) < 0 || *tmp != ':' ||
|
virStrToLong_ui(tmp + 1, &tmp, 16, &devAddr.bus) < 0 || *tmp != ':' ||
|
||||||
/* slot */
|
/* slot */
|
||||||
virStrToLong_ui(tmp + 1, &tmp, 16, &slot) < 0 || *tmp != '.' ||
|
virStrToLong_ui(tmp + 1, &tmp, 16, &devAddr.slot) < 0 || *tmp != '.' ||
|
||||||
/* function */
|
/* function */
|
||||||
virStrToLong_ui(tmp + 1, NULL, 16, &function) < 0) {
|
virStrToLong_ui(tmp + 1, NULL, 16, &devAddr.function) < 0) {
|
||||||
VIR_WARN("Unusual entry in " PCI_SYSFS "devices: %s", entry->d_name);
|
VIR_WARN("Unusual entry in " PCI_SYSFS "devices: %s", entry->d_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
check = virPCIDeviceNew(domain, bus, slot, function);
|
check = virPCIDeviceNew(&devAddr);
|
||||||
if (!check) {
|
if (!check) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
|
@ -767,10 +767,7 @@ virPCIDeviceIsParent(virPCIDevicePtr dev, virPCIDevicePtr check, void *data)
|
||||||
*/
|
*/
|
||||||
if (dev->address.bus > secondary && dev->address.bus <= subordinate) {
|
if (dev->address.bus > secondary && dev->address.bus <= subordinate) {
|
||||||
if (*best == NULL) {
|
if (*best == NULL) {
|
||||||
*best = virPCIDeviceNew(check->address.domain,
|
*best = virPCIDeviceNew(&check->address);
|
||||||
check->address.bus,
|
|
||||||
check->address.slot,
|
|
||||||
check->address.function);
|
|
||||||
if (*best == NULL) {
|
if (*best == NULL) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -790,10 +787,7 @@ virPCIDeviceIsParent(virPCIDevicePtr dev, virPCIDevicePtr check, void *data)
|
||||||
|
|
||||||
if (secondary > best_secondary) {
|
if (secondary > best_secondary) {
|
||||||
virPCIDeviceFree(*best);
|
virPCIDeviceFree(*best);
|
||||||
*best = virPCIDeviceNew(check->address.domain,
|
*best = virPCIDeviceNew(&check->address);
|
||||||
check->address.bus,
|
|
||||||
check->address.slot,
|
|
||||||
check->address.function);
|
|
||||||
if (*best == NULL) {
|
if (*best == NULL) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -1455,10 +1449,7 @@ virPCIDeviceAddressAsString(const virPCIDeviceAddress *addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
virPCIDevicePtr
|
virPCIDevicePtr
|
||||||
virPCIDeviceNew(unsigned int domain,
|
virPCIDeviceNew(const virPCIDeviceAddress *address)
|
||||||
unsigned int bus,
|
|
||||||
unsigned int slot,
|
|
||||||
unsigned int function)
|
|
||||||
{
|
{
|
||||||
g_autoptr(virPCIDevice) dev = NULL;
|
g_autoptr(virPCIDevice) dev = NULL;
|
||||||
g_autofree char *vendor = NULL;
|
g_autofree char *vendor = NULL;
|
||||||
|
@ -1466,10 +1457,7 @@ virPCIDeviceNew(unsigned int domain,
|
||||||
|
|
||||||
dev = g_new0(virPCIDevice, 1);
|
dev = g_new0(virPCIDevice, 1);
|
||||||
|
|
||||||
dev->address.domain = domain;
|
virPCIDeviceAddressCopy(&dev->address, address);
|
||||||
dev->address.bus = bus;
|
|
||||||
dev->address.slot = slot;
|
|
||||||
dev->address.function = function;
|
|
||||||
|
|
||||||
dev->name = virPCIDeviceAddressAsString(&dev->address);
|
dev->name = virPCIDeviceAddressAsString(&dev->address);
|
||||||
|
|
||||||
|
@ -1896,8 +1884,7 @@ virPCIDeviceGetIOMMUGroupAddOne(virPCIDeviceAddressPtr newDevAddr, void *opaque)
|
||||||
virPCIDeviceListPtr groupList = opaque;
|
virPCIDeviceListPtr groupList = opaque;
|
||||||
g_autoptr(virPCIDevice) newDev = NULL;
|
g_autoptr(virPCIDevice) newDev = NULL;
|
||||||
|
|
||||||
if (!(newDev = virPCIDeviceNew(newDevAddr->domain, newDevAddr->bus,
|
if (!(newDev = virPCIDeviceNew(newDevAddr)))
|
||||||
newDevAddr->slot, newDevAddr->function)))
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virPCIDeviceListAdd(groupList, newDev) < 0)
|
if (virPCIDeviceListAdd(groupList, newDev) < 0)
|
||||||
|
@ -2028,10 +2015,7 @@ virPCIDeviceAddressGetIOMMUGroupDev(const virPCIDeviceAddress *devAddr)
|
||||||
{
|
{
|
||||||
g_autoptr(virPCIDevice) pci = NULL;
|
g_autoptr(virPCIDevice) pci = NULL;
|
||||||
|
|
||||||
if (!(pci = virPCIDeviceNew(devAddr->domain,
|
if (!(pci = virPCIDeviceNew(devAddr)))
|
||||||
devAddr->bus,
|
|
||||||
devAddr->slot,
|
|
||||||
devAddr->function)))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return virPCIDeviceGetIOMMUGroupDev(pci);
|
return virPCIDeviceGetIOMMUGroupDev(pci);
|
||||||
|
|
|
@ -118,10 +118,7 @@ struct _virPCIEDeviceInfo {
|
||||||
virPCIELink *link_sta; /* Actually negotiated capabilities */
|
virPCIELink *link_sta; /* Actually negotiated capabilities */
|
||||||
};
|
};
|
||||||
|
|
||||||
virPCIDevicePtr virPCIDeviceNew(unsigned int domain,
|
virPCIDevicePtr virPCIDeviceNew(const virPCIDeviceAddress *address);
|
||||||
unsigned int bus,
|
|
||||||
unsigned int slot,
|
|
||||||
unsigned int function);
|
|
||||||
virPCIDevicePtr virPCIDeviceCopy(virPCIDevicePtr dev);
|
virPCIDevicePtr virPCIDeviceCopy(virPCIDevicePtr dev);
|
||||||
void virPCIDeviceFree(virPCIDevicePtr dev);
|
void virPCIDeviceFree(virPCIDevicePtr dev);
|
||||||
const char *virPCIDeviceGetName(virPCIDevicePtr dev);
|
const char *virPCIDeviceGetName(virPCIDevicePtr dev);
|
||||||
|
|
|
@ -138,7 +138,8 @@ myInit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nhostdevs; i++) {
|
for (i = 0; i < nhostdevs; i++) {
|
||||||
if (!(dev[i] = virPCIDeviceNew(0, 0, i + 1, 0)))
|
virDomainHostdevSubsys subsys = hostdevs[i]->source.subsys;
|
||||||
|
if (!(dev[i] = virPCIDeviceNew(&subsys.u.pci.addr)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_VFIO);
|
virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_VFIO);
|
||||||
|
|
|
@ -60,8 +60,9 @@ testVirPCIDeviceNew(const void *opaque G_GNUC_UNUSED)
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virPCIDevicePtr dev;
|
virPCIDevicePtr dev;
|
||||||
const char *devName;
|
const char *devName;
|
||||||
|
virPCIDeviceAddress devAddr = {.domain = 0, .bus = 0, .slot = 0, .function = 0};
|
||||||
|
|
||||||
if (!(dev = virPCIDeviceNew(0, 0, 0, 0)))
|
if (!(dev = virPCIDeviceNew(&devAddr)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
devName = virPCIDeviceGetName(dev);
|
devName = virPCIDeviceGetName(dev);
|
||||||
|
@ -103,7 +104,9 @@ testVirPCIDeviceDetach(const void *opaque G_GNUC_UNUSED)
|
||||||
CHECK_LIST_COUNT(inactiveDevs, 0);
|
CHECK_LIST_COUNT(inactiveDevs, 0);
|
||||||
|
|
||||||
for (i = 0; i < nDev; i++) {
|
for (i = 0; i < nDev; i++) {
|
||||||
if (!(dev[i] = virPCIDeviceNew(0, 0, i + 1, 0)))
|
virPCIDeviceAddress devAddr = {.domain = 0, .bus = 0,
|
||||||
|
.slot = i + 1, .function = 0};
|
||||||
|
if (!(dev[i] = virPCIDeviceNew(&devAddr)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_VFIO);
|
virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_VFIO);
|
||||||
|
@ -144,7 +147,9 @@ testVirPCIDeviceReset(const void *opaque G_GNUC_UNUSED)
|
||||||
CHECK_LIST_COUNT(inactiveDevs, 0);
|
CHECK_LIST_COUNT(inactiveDevs, 0);
|
||||||
|
|
||||||
for (i = 0; i < nDev; i++) {
|
for (i = 0; i < nDev; i++) {
|
||||||
if (!(dev[i] = virPCIDeviceNew(0, 0, i + 1, 0)))
|
virPCIDeviceAddress devAddr = {.domain = 0, .bus = 0,
|
||||||
|
.slot = i + 1, .function = 0};
|
||||||
|
if (!(dev[i] = virPCIDeviceNew(&devAddr)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_VFIO);
|
virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_VFIO);
|
||||||
|
@ -176,7 +181,9 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUSED)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < nDev; i++) {
|
for (i = 0; i < nDev; i++) {
|
||||||
if (!(dev[i] = virPCIDeviceNew(0, 0, i + 1, 0)))
|
virPCIDeviceAddress devAddr = {.domain = 0, .bus = 0,
|
||||||
|
.slot = i + 1, .function = 0};
|
||||||
|
if (!(dev[i] = virPCIDeviceNew(&devAddr)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virPCIDeviceListAdd(inactiveDevs, dev[i]) < 0) {
|
if (virPCIDeviceListAdd(inactiveDevs, dev[i]) < 0) {
|
||||||
|
@ -222,8 +229,10 @@ testVirPCIDeviceIsAssignable(const void *opaque)
|
||||||
const struct testPCIDevData *data = opaque;
|
const struct testPCIDevData *data = opaque;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virPCIDevicePtr dev;
|
virPCIDevicePtr dev;
|
||||||
|
virPCIDeviceAddress devAddr = {.domain = data->domain, .bus = data->bus,
|
||||||
|
.slot = data->slot, .function = data->function};
|
||||||
|
|
||||||
if (!(dev = virPCIDeviceNew(data->domain, data->bus, data->slot, data->function)))
|
if (!(dev = virPCIDeviceNew(&devAddr)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virPCIDeviceIsAssignable(dev, true))
|
if (virPCIDeviceIsAssignable(dev, true))
|
||||||
|
@ -239,8 +248,10 @@ testVirPCIDeviceDetachSingle(const void *opaque)
|
||||||
const struct testPCIDevData *data = opaque;
|
const struct testPCIDevData *data = opaque;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virPCIDevicePtr dev;
|
virPCIDevicePtr dev;
|
||||||
|
virPCIDeviceAddress devAddr = {.domain = data->domain, .bus = data->bus,
|
||||||
|
.slot = data->slot, .function = data->function};
|
||||||
|
|
||||||
dev = virPCIDeviceNew(data->domain, data->bus, data->slot, data->function);
|
dev = virPCIDeviceNew(&devAddr);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -261,8 +272,10 @@ testVirPCIDeviceReattachSingle(const void *opaque)
|
||||||
const struct testPCIDevData *data = opaque;
|
const struct testPCIDevData *data = opaque;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virPCIDevicePtr dev;
|
virPCIDevicePtr dev;
|
||||||
|
virPCIDeviceAddress devAddr = {.domain = data->domain, .bus = data->bus,
|
||||||
|
.slot = data->slot, .function = data->function};
|
||||||
|
|
||||||
dev = virPCIDeviceNew(data->domain, data->bus, data->slot, data->function);
|
dev = virPCIDeviceNew(&devAddr);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -285,8 +298,10 @@ testVirPCIDeviceCheckDriverTest(const void *opaque)
|
||||||
const struct testPCIDevData *data = opaque;
|
const struct testPCIDevData *data = opaque;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virPCIDevicePtr dev;
|
virPCIDevicePtr dev;
|
||||||
|
virPCIDeviceAddress devAddr = {.domain = data->domain, .bus = data->bus,
|
||||||
|
.slot = data->slot, .function = data->function};
|
||||||
|
|
||||||
dev = virPCIDeviceNew(data->domain, data->bus, data->slot, data->function);
|
dev = virPCIDeviceNew(&devAddr);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -305,8 +320,10 @@ testVirPCIDeviceUnbind(const void *opaque)
|
||||||
const struct testPCIDevData *data = opaque;
|
const struct testPCIDevData *data = opaque;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virPCIDevicePtr dev;
|
virPCIDevicePtr dev;
|
||||||
|
virPCIDeviceAddress devAddr = {.domain = data->domain, .bus = data->bus,
|
||||||
|
.slot = data->slot, .function = data->function};
|
||||||
|
|
||||||
dev = virPCIDeviceNew(data->domain, data->bus, data->slot, data->function);
|
dev = virPCIDeviceNew(&devAddr);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue