Rename all PCI device functions to have a standard name prefix

Rename all the pciDeviceXXX and pciXXXDevice APIs to have a
fixed virPCIDevice name prefix
This commit is contained in:
Daniel P. Berrange 2013-01-14 22:11:44 +00:00
parent b46f7f4a0b
commit 202535601c
20 changed files with 704 additions and 693 deletions

View File

@ -36,7 +36,6 @@
#include "virutil.h"
#include "virbuffer.h"
#include "viruuid.h"
#include "virpci.h"
#include "virrandom.h"
#define VIR_FROM_THIS VIR_FROM_NODEDEV

View File

@ -28,6 +28,7 @@
# include "internal.h"
# include "virutil.h"
# include "virthread.h"
# include "virpci.h"
# include <libxml/tree.h>
@ -111,8 +112,8 @@ struct _virNodeDevCapsDef {
unsigned int class;
char *product_name;
char *vendor_name;
struct pci_config_address *physical_function;
struct pci_config_address **virtual_functions;
virPCIDeviceAddressPtr physical_function;
virPCIDeviceAddressPtr *virtual_functions;
unsigned int num_virtual_functions;
unsigned int flags;
} pci_dev;

View File

@ -992,43 +992,43 @@ virNWFilterVarValueGetSimple;
# pci.h
pciConfigAddressToSysfsFile;
pciDettachDevice;
pciDeviceFileIterate;
pciDeviceGetManaged;
pciDeviceGetName;
pciDeviceGetRemoveSlot;
pciDeviceGetReprobe;
pciDeviceGetUnbindFromStub;
pciDeviceGetUsedBy;
pciDeviceGetVirtualFunctionInfo;
pciDeviceIsAssignable;
pciDeviceIsVirtualFunction;
pciDeviceListAdd;
pciDeviceListCount;
pciDeviceListDel;
pciDeviceListFind;
pciDeviceListFindIndex;
pciDeviceListFree;
pciDeviceListGet;
pciDeviceListNew;
pciDeviceListSteal;
pciDeviceListStealIndex;
pciDeviceNetName;
pciDeviceReAttachInit;
pciDeviceSetManaged;
pciDeviceSetRemoveSlot;
pciDeviceSetReprobe;
pciDeviceSetUnbindFromStub;
pciDeviceSetUsedBy;
pciFreeDevice;
pciGetDevice;
pciGetPhysicalFunction;
pciGetVirtualFunctionIndex;
pciGetVirtualFunctions;
pciReAttachDevice;
pciResetDevice;
pciWaitForDeviceCleanup;
virPCIDeviceAddressGetSysfsFile;
virPCIDeviceDetach;
virPCIDeviceFileIterate;
virPCIDeviceFree;
virPCIDeviceGetManaged;
virPCIDeviceGetName;
virPCIDeviceGetRemoveSlot;
virPCIDeviceGetReprobe;
virPCIDeviceGetUnbindFromStub;
virPCIDeviceGetUsedBy;
virPCIDeviceIsAssignable;
virPCIDeviceListAdd;
virPCIDeviceListCount;
virPCIDeviceListDel;
virPCIDeviceListFind;
virPCIDeviceListFindIndex;
virPCIDeviceListFree;
virPCIDeviceListGet;
virPCIDeviceListNew;
virPCIDeviceListSteal;
virPCIDeviceListStealIndex;
virPCIDeviceNew;
virPCIDeviceReattach;
virPCIDeviceReattachInit;
virPCIDeviceReset;
virPCIDeviceSetManaged;
virPCIDeviceSetRemoveSlot;
virPCIDeviceSetReprobe;
virPCIDeviceSetUnbindFromStub;
virPCIDeviceSetUsedBy;
virPCIDeviceWaitForCleanup;
virPCIGetNetName;
virPCIGetPhysicalFunction;
virPCIGetVirtualFunctionIndex;
virPCIGetVirtualFunctionInfo;
virPCIGetVirtualFunctions;
virPCIIsVirtualFunction;
# secret_conf.h

View File

@ -3622,7 +3622,7 @@ static int
networkCreateInterfacePool(virNetworkDefPtr netdef) {
unsigned int num_virt_fns = 0;
char **vfname = NULL;
struct pci_config_address **virt_fns;
virPCIDeviceAddressPtr *virt_fns;
int ret = -1, ii = 0;
if ((virNetDevGetVirtualFunctions(netdef->forward.pfs->dev,

View File

@ -481,10 +481,10 @@ static int udevProcessPCI(struct udev_device *device,
goto out;
}
if (!pciGetPhysicalFunction(syspath, &data->pci_dev.physical_function))
if (!virPCIGetPhysicalFunction(syspath, &data->pci_dev.physical_function))
data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;
if (!pciGetVirtualFunctions(syspath, &data->pci_dev.virtual_functions,
if (!virPCIGetVirtualFunctions(syspath, &data->pci_dev.virtual_functions,
&data->pci_dev.num_virtual_functions) ||
data->pci_dev.num_virtual_functions > 0)
data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;

View File

@ -33,7 +33,6 @@
#include <sys/time.h>
#include "qemu_agent.h"
#include "qemu_command.h"
#include "viralloc.h"
#include "virlog.h"
#include "virerror.h"

View File

@ -181,11 +181,10 @@ struct _virQEMUDriver {
virSecurityManagerPtr securityManager;
pciDeviceList *activePciHostdevs;
virPCIDeviceListPtr activePciHostdevs;
virPCIDeviceListPtr inactivePciHostdevs;
usbDeviceList *activeUsbHostdevs;
pciDeviceList *inactivePciHostdevs;
virHashTablePtr sharedDisks;
virPortAllocatorPtr remotePorts;

View File

@ -774,13 +774,13 @@ qemuStartup(bool privileged,
if (qemuSecurityInit(qemu_driver) < 0)
goto error;
if ((qemu_driver->activePciHostdevs = pciDeviceListNew()) == NULL)
if ((qemu_driver->activePciHostdevs = virPCIDeviceListNew()) == NULL)
goto error;
if ((qemu_driver->activeUsbHostdevs = usbDeviceListNew()) == NULL)
goto error;
if ((qemu_driver->inactivePciHostdevs = pciDeviceListNew()) == NULL)
if ((qemu_driver->inactivePciHostdevs = virPCIDeviceListNew()) == NULL)
goto error;
if (!(qemu_driver->sharedDisks = virHashCreate(30, NULL)))
@ -1047,8 +1047,8 @@ qemuShutdown(void) {
qemuDriverLock(qemu_driver);
virNWFilterUnRegisterCallbackDriver(&qemuCallbackDriver);
pciDeviceListFree(qemu_driver->activePciHostdevs);
pciDeviceListFree(qemu_driver->inactivePciHostdevs);
virPCIDeviceListFree(qemu_driver->activePciHostdevs);
virPCIDeviceListFree(qemu_driver->inactivePciHostdevs);
usbDeviceListFree(qemu_driver->activeUsbHostdevs);
virHashFree(qemu_driver->sharedDisks);
virCapabilitiesFree(qemu_driver->caps);
@ -10021,7 +10021,7 @@ static int
qemuNodeDeviceDettach(virNodeDevicePtr dev)
{
virQEMUDriverPtr driver = dev->conn->privateData;
pciDevice *pci;
virPCIDevicePtr pci;
unsigned domain, bus, slot, function;
int ret = -1;
bool in_inactive_list = false;
@ -10029,22 +10029,22 @@ qemuNodeDeviceDettach(virNodeDevicePtr dev)
if (qemuNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
return -1;
pci = pciGetDevice(domain, bus, slot, function);
pci = virPCIDeviceNew(domain, bus, slot, function);
if (!pci)
return -1;
qemuDriverLock(driver);
in_inactive_list = pciDeviceListFind(driver->inactivePciHostdevs, pci);
in_inactive_list = virPCIDeviceListFind(driver->inactivePciHostdevs, pci);
if (pciDettachDevice(pci, driver->activePciHostdevs,
driver->inactivePciHostdevs, "pci-stub") < 0)
if (virPCIDeviceDetach(pci, driver->activePciHostdevs,
driver->inactivePciHostdevs, "pci-stub") < 0)
goto out;
ret = 0;
out:
qemuDriverUnlock(driver);
if (in_inactive_list)
pciFreeDevice(pci);
virPCIDeviceFree(pci);
return ret;
}
@ -10052,43 +10052,43 @@ static int
qemuNodeDeviceReAttach(virNodeDevicePtr dev)
{
virQEMUDriverPtr driver = dev->conn->privateData;
pciDevice *pci;
pciDevice *other;
virPCIDevicePtr pci;
virPCIDevicePtr other;
unsigned domain, bus, slot, function;
int ret = -1;
if (qemuNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
return -1;
pci = pciGetDevice(domain, bus, slot, function);
pci = virPCIDeviceNew(domain, bus, slot, function);
if (!pci)
return -1;
other = pciDeviceListFind(driver->activePciHostdevs, pci);
other = virPCIDeviceListFind(driver->activePciHostdevs, pci);
if (other) {
const char *other_name = pciDeviceGetUsedBy(other);
const char *other_name = virPCIDeviceGetUsedBy(other);
if (other_name)
virReportError(VIR_ERR_OPERATION_INVALID,
_("PCI device %s is still in use by domain %s"),
pciDeviceGetName(pci), other_name);
virPCIDeviceGetName(pci), other_name);
else
virReportError(VIR_ERR_OPERATION_INVALID,
_("PCI device %s is still in use"),
pciDeviceGetName(pci));
virPCIDeviceGetName(pci));
}
pciDeviceReAttachInit(pci);
virPCIDeviceReattachInit(pci);
qemuDriverLock(driver);
if (pciReAttachDevice(pci, driver->activePciHostdevs,
driver->inactivePciHostdevs, "pci-stub") < 0)
if (virPCIDeviceReattach(pci, driver->activePciHostdevs,
driver->inactivePciHostdevs, "pci-stub") < 0)
goto out;
ret = 0;
out:
qemuDriverUnlock(driver);
pciFreeDevice(pci);
virPCIDeviceFree(pci);
return ret;
}
@ -10096,27 +10096,27 @@ static int
qemuNodeDeviceReset(virNodeDevicePtr dev)
{
virQEMUDriverPtr driver = dev->conn->privateData;
pciDevice *pci;
virPCIDevicePtr pci;
unsigned domain, bus, slot, function;
int ret = -1;
if (qemuNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
return -1;
pci = pciGetDevice(domain, bus, slot, function);
pci = virPCIDeviceNew(domain, bus, slot, function);
if (!pci)
return -1;
qemuDriverLock(driver);
if (pciResetDevice(pci, driver->activePciHostdevs,
driver->inactivePciHostdevs) < 0)
if (virPCIDeviceReset(pci, driver->activePciHostdevs,
driver->inactivePciHostdevs) < 0)
goto out;
ret = 0;
out:
qemuDriverUnlock(driver);
pciFreeDevice(pci);
virPCIDeviceFree(pci);
return ret;
}

View File

@ -33,84 +33,84 @@
#define VIR_FROM_THIS VIR_FROM_QEMU
static pciDeviceList *
static virPCIDeviceListPtr
qemuGetPciHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
{
pciDeviceList *list;
virPCIDeviceListPtr list;
int i;
if (!(list = pciDeviceListNew()))
if (!(list = virPCIDeviceListNew()))
return NULL;
for (i = 0 ; i < nhostdevs ; i++) {
virDomainHostdevDefPtr hostdev = hostdevs[i];
pciDevice *dev;
virPCIDevicePtr dev;
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
continue;
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
continue;
dev = pciGetDevice(hostdev->source.subsys.u.pci.domain,
hostdev->source.subsys.u.pci.bus,
hostdev->source.subsys.u.pci.slot,
hostdev->source.subsys.u.pci.function);
dev = virPCIDeviceNew(hostdev->source.subsys.u.pci.domain,
hostdev->source.subsys.u.pci.bus,
hostdev->source.subsys.u.pci.slot,
hostdev->source.subsys.u.pci.function);
if (!dev) {
pciDeviceListFree(list);
virPCIDeviceListFree(list);
return NULL;
}
if (pciDeviceListAdd(list, dev) < 0) {
pciFreeDevice(dev);
pciDeviceListFree(list);
if (virPCIDeviceListAdd(list, dev) < 0) {
virPCIDeviceFree(dev);
virPCIDeviceListFree(list);
return NULL;
}
pciDeviceSetManaged(dev, hostdev->managed);
virPCIDeviceSetManaged(dev, hostdev->managed);
}
return list;
}
static pciDeviceList *
static virPCIDeviceListPtr
qemuGetActivePciHostDeviceList(virQEMUDriverPtr driver,
virDomainHostdevDefPtr *hostdevs,
int nhostdevs)
{
pciDeviceList *list;
virPCIDeviceListPtr list;
int i;
if (!(list = pciDeviceListNew()))
if (!(list = virPCIDeviceListNew()))
return NULL;
for (i = 0 ; i < nhostdevs ; i++) {
virDomainHostdevDefPtr hostdev = hostdevs[i];
pciDevice *dev;
pciDevice *activeDev;
virPCIDevicePtr dev;
virPCIDevicePtr activeDev;
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
continue;
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
continue;
dev = pciGetDevice(hostdev->source.subsys.u.pci.domain,
hostdev->source.subsys.u.pci.bus,
hostdev->source.subsys.u.pci.slot,
hostdev->source.subsys.u.pci.function);
dev = virPCIDeviceNew(hostdev->source.subsys.u.pci.domain,
hostdev->source.subsys.u.pci.bus,
hostdev->source.subsys.u.pci.slot,
hostdev->source.subsys.u.pci.function);
if (!dev) {
pciDeviceListFree(list);
virPCIDeviceListFree(list);
return NULL;
}
if ((activeDev = pciDeviceListFind(driver->activePciHostdevs, dev))) {
if (pciDeviceListAdd(list, activeDev) < 0) {
pciFreeDevice(dev);
pciDeviceListFree(list);
if ((activeDev = virPCIDeviceListFind(driver->activePciHostdevs, dev))) {
if (virPCIDeviceListAdd(list, activeDev) < 0) {
virPCIDeviceFree(dev);
virPCIDeviceListFree(list);
return NULL;
}
}
pciFreeDevice(dev);
virPCIDeviceFree(dev);
}
return list;
@ -126,7 +126,7 @@ int qemuUpdateActivePciHostdevs(virQEMUDriverPtr driver,
return 0;
for (i = 0; i < def->nhostdevs; i++) {
pciDevice *dev = NULL;
virPCIDevicePtr dev = NULL;
hostdev = def->hostdevs[i];
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
@ -134,24 +134,24 @@ int qemuUpdateActivePciHostdevs(virQEMUDriverPtr driver,
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
continue;
dev = pciGetDevice(hostdev->source.subsys.u.pci.domain,
hostdev->source.subsys.u.pci.bus,
hostdev->source.subsys.u.pci.slot,
hostdev->source.subsys.u.pci.function);
dev = virPCIDeviceNew(hostdev->source.subsys.u.pci.domain,
hostdev->source.subsys.u.pci.bus,
hostdev->source.subsys.u.pci.slot,
hostdev->source.subsys.u.pci.function);
if (!dev)
return -1;
pciDeviceSetManaged(dev, hostdev->managed);
pciDeviceSetUsedBy(dev, def->name);
virPCIDeviceSetManaged(dev, hostdev->managed);
virPCIDeviceSetUsedBy(dev, def->name);
/* Setup the original states for the PCI device */
pciDeviceSetUnbindFromStub(dev, hostdev->origstates.states.pci.unbind_from_stub);
pciDeviceSetRemoveSlot(dev, hostdev->origstates.states.pci.remove_slot);
pciDeviceSetReprobe(dev, hostdev->origstates.states.pci.reprobe);
virPCIDeviceSetUnbindFromStub(dev, hostdev->origstates.states.pci.unbind_from_stub);
virPCIDeviceSetRemoveSlot(dev, hostdev->origstates.states.pci.remove_slot);
virPCIDeviceSetReprobe(dev, hostdev->origstates.states.pci.reprobe);
if (pciDeviceListAdd(driver->activePciHostdevs, dev) < 0) {
pciFreeDevice(dev);
if (virPCIDeviceListAdd(driver->activePciHostdevs, dev) < 0) {
virPCIDeviceFree(dev);
return -1;
}
}
@ -203,14 +203,14 @@ qemuUpdateActiveUsbHostdevs(virQEMUDriverPtr driver,
static int
qemuDomainHostdevPciSysfsPath(virDomainHostdevDefPtr hostdev, char **sysfs_path)
{
struct pci_config_address config_address;
virPCIDeviceAddress config_address;
config_address.domain = hostdev->source.subsys.u.pci.domain;
config_address.bus = hostdev->source.subsys.u.pci.bus;
config_address.slot = hostdev->source.subsys.u.pci.slot;
config_address.function = hostdev->source.subsys.u.pci.function;
return pciConfigAddressToSysfsFile(&config_address, sysfs_path);
return virPCIDeviceAddressGetSysfsFile(&config_address, sysfs_path);
}
int
@ -222,7 +222,7 @@ qemuDomainHostdevIsVirtualFunction(virDomainHostdevDefPtr hostdev)
if (qemuDomainHostdevPciSysfsPath(hostdev, &sysfs_path) < 0)
return ret;
ret = pciDeviceIsVirtualFunction(sysfs_path);
ret = virPCIIsVirtualFunction(sysfs_path);
VIR_FREE(sysfs_path);
@ -239,12 +239,12 @@ qemuDomainHostdevNetDevice(virDomainHostdevDefPtr hostdev, char **linkdev,
if (qemuDomainHostdevPciSysfsPath(hostdev, &sysfs_path) < 0)
return ret;
if (pciDeviceIsVirtualFunction(sysfs_path) == 1) {
if (pciDeviceGetVirtualFunctionInfo(sysfs_path, linkdev,
vf) < 0)
if (virPCIIsVirtualFunction(sysfs_path) == 1) {
if (virPCIGetVirtualFunctionInfo(sysfs_path, linkdev,
vf) < 0)
goto cleanup;
} else {
if (pciDeviceNetName(sysfs_path, linkdev) < 0)
if (virPCIGetNetName(sysfs_path, linkdev) < 0)
goto cleanup;
*vf = -1;
}
@ -406,7 +406,7 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
virDomainHostdevDefPtr *hostdevs,
int nhostdevs)
{
pciDeviceList *pcidevs;
virPCIDeviceListPtr pcidevs;
int last_processed_hostdev_vf = -1;
int i;
int ret = -1;
@ -427,48 +427,48 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
* to pci-stub.ko
*/
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
pciDevice *other;
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
virPCIDevicePtr other;
if (!pciDeviceIsAssignable(dev, !cfg->relaxedACS)) {
if (!virPCIDeviceIsAssignable(dev, !cfg->relaxedACS)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("PCI device %s is not assignable"),
pciDeviceGetName(dev));
virPCIDeviceGetName(dev));
goto cleanup;
}
/* The device is in use by other active domain if
* the dev is in list driver->activePciHostdevs.
*/
if ((other = pciDeviceListFind(driver->activePciHostdevs, dev))) {
const char *other_name = pciDeviceGetUsedBy(other);
if ((other = virPCIDeviceListFind(driver->activePciHostdevs, dev))) {
const char *other_name = virPCIDeviceGetUsedBy(other);
if (other_name)
virReportError(VIR_ERR_OPERATION_INVALID,
_("PCI device %s is in use by domain %s"),
pciDeviceGetName(dev), other_name);
virPCIDeviceGetName(dev), other_name);
else
virReportError(VIR_ERR_OPERATION_INVALID,
_("PCI device %s is already in use"),
pciDeviceGetName(dev));
virPCIDeviceGetName(dev));
goto cleanup;
}
}
/* Loop 2: detach managed devices */
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
if (pciDeviceGetManaged(dev) &&
pciDettachDevice(dev, driver->activePciHostdevs, NULL, "pci-stub") < 0)
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
if (virPCIDeviceGetManaged(dev) &&
virPCIDeviceDetach(dev, driver->activePciHostdevs, NULL, "pci-stub") < 0)
goto reattachdevs;
}
/* Loop 3: Now that all the PCI hostdevs have been detached, we
* can safely reset them */
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
if (pciResetDevice(dev, driver->activePciHostdevs,
driver->inactivePciHostdevs) < 0)
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
if (virPCIDeviceReset(dev, driver->activePciHostdevs,
driver->inactivePciHostdevs) < 0)
goto reattachdevs;
}
@ -491,35 +491,35 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
}
/* Loop 5: Now mark all the devices as active */
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
if (pciDeviceListAdd(driver->activePciHostdevs, dev) < 0)
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
if (virPCIDeviceListAdd(driver->activePciHostdevs, dev) < 0)
goto inactivedevs;
}
/* Loop 6: Now remove the devices from inactive list. */
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
pciDeviceListDel(driver->inactivePciHostdevs, dev);
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
virPCIDeviceListDel(driver->inactivePciHostdevs, dev);
}
/* Loop 7: Now set the used_by_domain of the device in
* driver->activePciHostdevs as domain name.
*/
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev, *activeDev;
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev, activeDev;
dev = pciDeviceListGet(pcidevs, i);
activeDev = pciDeviceListFind(driver->activePciHostdevs, dev);
dev = virPCIDeviceListGet(pcidevs, i);
activeDev = virPCIDeviceListFind(driver->activePciHostdevs, dev);
if (activeDev)
pciDeviceSetUsedBy(activeDev, name);
virPCIDeviceSetUsedBy(activeDev, name);
}
/* Loop 8: Now set the original states for hostdev def */
for (i = 0; i < nhostdevs; i++) {
pciDevice *dev;
pciDevice *pcidev;
virPCIDevicePtr dev;
virPCIDevicePtr pcidev;
virDomainHostdevDefPtr hostdev = hostdevs[i];
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
@ -527,41 +527,41 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
continue;
dev = pciGetDevice(hostdev->source.subsys.u.pci.domain,
hostdev->source.subsys.u.pci.bus,
hostdev->source.subsys.u.pci.slot,
hostdev->source.subsys.u.pci.function);
dev = virPCIDeviceNew(hostdev->source.subsys.u.pci.domain,
hostdev->source.subsys.u.pci.bus,
hostdev->source.subsys.u.pci.slot,
hostdev->source.subsys.u.pci.function);
/* original states "unbind_from_stub", "remove_slot",
* "reprobe" were already set by pciDettachDevice in
* loop 2.
*/
if ((pcidev = pciDeviceListFind(pcidevs, dev))) {
if ((pcidev = virPCIDeviceListFind(pcidevs, dev))) {
hostdev->origstates.states.pci.unbind_from_stub =
pciDeviceGetUnbindFromStub(pcidev);
virPCIDeviceGetUnbindFromStub(pcidev);
hostdev->origstates.states.pci.remove_slot =
pciDeviceGetRemoveSlot(pcidev);
virPCIDeviceGetRemoveSlot(pcidev);
hostdev->origstates.states.pci.reprobe =
pciDeviceGetReprobe(pcidev);
virPCIDeviceGetReprobe(pcidev);
}
pciFreeDevice(dev);
virPCIDeviceFree(dev);
}
/* Loop 9: Now steal all the devices from pcidevs */
while (pciDeviceListCount(pcidevs) > 0)
pciDeviceListStealIndex(pcidevs, 0);
while (virPCIDeviceListCount(pcidevs) > 0)
virPCIDeviceListStealIndex(pcidevs, 0);
ret = 0;
goto cleanup;
inactivedevs:
/* Only steal all the devices from driver->activePciHostdevs. We will
* free them in pciDeviceListFree().
* free them in virPCIDeviceListFree().
*/
while (pciDeviceListCount(pcidevs) > 0) {
pciDevice *dev = pciDeviceListGet(pcidevs, 0);
pciDeviceListSteal(driver->activePciHostdevs, dev);
while (virPCIDeviceListCount(pcidevs) > 0) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, 0);
virPCIDeviceListSteal(driver->activePciHostdevs, dev);
}
resetvfnetconfig:
@ -574,13 +574,13 @@ resetvfnetconfig:
}
reattachdevs:
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
pciReAttachDevice(dev, driver->activePciHostdevs, NULL, "pci-stub");
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
virPCIDeviceReattach(dev, driver->activePciHostdevs, NULL, "pci-stub");
}
cleanup:
pciDeviceListFree(pcidevs);
virPCIDeviceListFree(pcidevs);
virObjectUnref(cfg);
return ret;
}
@ -813,33 +813,33 @@ int qemuPrepareHostDevices(virQEMUDriverPtr driver,
}
void qemuReattachPciDevice(pciDevice *dev, virQEMUDriverPtr driver)
void qemuReattachPciDevice(virPCIDevicePtr dev, virQEMUDriverPtr driver)
{
int retries = 100;
/* If the device is not managed and was attached to guest
* successfully, it must have been inactive.
*/
if (!pciDeviceGetManaged(dev)) {
if (pciDeviceListAdd(driver->inactivePciHostdevs, dev) < 0)
pciFreeDevice(dev);
if (!virPCIDeviceGetManaged(dev)) {
if (virPCIDeviceListAdd(driver->inactivePciHostdevs, dev) < 0)
virPCIDeviceFree(dev);
return;
}
while (pciWaitForDeviceCleanup(dev, "kvm_assigned_device")
while (virPCIDeviceWaitForCleanup(dev, "kvm_assigned_device")
&& retries) {
usleep(100*1000);
retries--;
}
if (pciReAttachDevice(dev, driver->activePciHostdevs,
driver->inactivePciHostdevs, "pci-stub") < 0) {
if (virPCIDeviceReattach(dev, driver->activePciHostdevs,
driver->inactivePciHostdevs, "pci-stub") < 0) {
virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to re-attach PCI device: %s"),
err ? err->message : _("unknown error"));
virResetError(err);
}
pciFreeDevice(dev);
virPCIDeviceFree(dev);
}
@ -848,7 +848,7 @@ void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
virDomainHostdevDefPtr *hostdevs,
int nhostdevs)
{
pciDeviceList *pcidevs;
virPCIDeviceListPtr pcidevs;
int i;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
@ -856,7 +856,7 @@ void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
hostdevs,
nhostdevs))) {
virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to allocate pciDeviceList: %s"),
VIR_ERROR(_("Failed to allocate PCI device list: %s"),
err ? err->message : _("unknown error"));
virResetError(err);
goto cleanup;
@ -866,22 +866,22 @@ void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
* them and reset all the devices before re-attach.
* Attach mac and port profile parameters to devices
*/
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
pciDevice *activeDev = NULL;
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
virPCIDevicePtr activeDev = NULL;
/* Never delete the dev from list driver->activePciHostdevs
* if it's used by other domain.
*/
activeDev = pciDeviceListFind(driver->activePciHostdevs, dev);
activeDev = virPCIDeviceListFind(driver->activePciHostdevs, dev);
if (activeDev &&
STRNEQ_NULLABLE(name, pciDeviceGetUsedBy(activeDev))) {
pciDeviceListSteal(pcidevs, dev);
STRNEQ_NULLABLE(name, virPCIDeviceGetUsedBy(activeDev))) {
virPCIDeviceListSteal(pcidevs, dev);
continue;
}
/* pciDeviceListFree() will take care of freeing the dev. */
pciDeviceListSteal(driver->activePciHostdevs, dev);
/* virPCIDeviceListFree() will take care of freeing the dev. */
virPCIDeviceListSteal(driver->activePciHostdevs, dev);
}
/*
@ -900,10 +900,10 @@ void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
}
}
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
if (pciResetDevice(dev, driver->activePciHostdevs,
driver->inactivePciHostdevs) < 0) {
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
if (virPCIDeviceReset(dev, driver->activePciHostdevs,
driver->inactivePciHostdevs) < 0) {
virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to reset PCI device: %s"),
err ? err->message : _("unknown error"));
@ -911,12 +911,12 @@ void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
}
}
while (pciDeviceListCount(pcidevs) > 0) {
pciDevice *dev = pciDeviceListStealIndex(pcidevs, 0);
while (virPCIDeviceListCount(pcidevs) > 0) {
virPCIDevicePtr dev = virPCIDeviceListStealIndex(pcidevs, 0);
qemuReattachPciDevice(dev, driver);
}
pciDeviceListFree(pcidevs);
virPCIDeviceListFree(pcidevs);
cleanup:
virObjectUnref(cfg);
}

View File

@ -45,7 +45,7 @@ int qemuPrepareHostdevUSBDevices(virQEMUDriverPtr driver,
int qemuPrepareHostDevices(virQEMUDriverPtr driver,
virDomainDefPtr def,
bool coldBoot);
void qemuReattachPciDevice(pciDevice *dev, virQEMUDriverPtr driver);
void qemuReattachPciDevice(virPCIDevicePtr dev, virQEMUDriverPtr driver);
void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
const char *name,
virDomainHostdevDefPtr *hostdevs,

View File

@ -2331,8 +2331,8 @@ qemuDomainDetachHostPciDevice(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainHostdevSubsysPtr subsys = &detach->source.subsys;
int ret = -1, rv;
pciDevice *pci;
pciDevice *activePci;
virPCIDevicePtr pci;
virPCIDevicePtr activePci;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
if (qemuIsMultiFunctionDevice(vm->def, detach->info)) {
@ -2368,20 +2368,20 @@ qemuDomainDetachHostPciDevice(virQEMUDriverPtr driver,
if (detach->parent.data.net)
qemuDomainHostdevNetConfigRestore(detach, cfg->stateDir);
pci = pciGetDevice(subsys->u.pci.domain, subsys->u.pci.bus,
subsys->u.pci.slot, subsys->u.pci.function);
pci = virPCIDeviceNew(subsys->u.pci.domain, subsys->u.pci.bus,
subsys->u.pci.slot, subsys->u.pci.function);
if (pci) {
activePci = pciDeviceListSteal(driver->activePciHostdevs, pci);
activePci = virPCIDeviceListSteal(driver->activePciHostdevs, pci);
if (activePci &&
pciResetDevice(activePci, driver->activePciHostdevs,
driver->inactivePciHostdevs) == 0) {
virPCIDeviceReset(activePci, driver->activePciHostdevs,
driver->inactivePciHostdevs) == 0) {
qemuReattachPciDevice(activePci, driver);
ret = 0;
} else {
/* reset of the device failed, treat it as if it was returned */
pciFreeDevice(activePci);
virPCIDeviceFree(activePci);
}
pciFreeDevice(pci);
virPCIDeviceFree(pci);
}
if (qemuCapsGet(priv->caps, QEMU_CAPS_DEVICE) &&

View File

@ -328,8 +328,8 @@ AppArmorSetSecurityUSBLabel(usbDevice *dev ATTRIBUTE_UNUSED,
}
static int
AppArmorSetSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
const char *file, void *opaque)
AppArmorSetSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
const char *file, void *opaque)
{
struct SDPDOP *ptr = opaque;
virDomainDefPtr def = ptr->def;
@ -783,16 +783,17 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain,
dev->source.subsys.u.pci.bus,
dev->source.subsys.u.pci.slot,
dev->source.subsys.u.pci.function);
virPCIDevicePtr pci =
virPCIDeviceNew(dev->source.subsys.u.pci.domain,
dev->source.subsys.u.pci.bus,
dev->source.subsys.u.pci.slot,
dev->source.subsys.u.pci.function);
if (!pci)
goto done;
ret = pciDeviceFileIterate(pci, AppArmorSetSecurityPCILabel, ptr);
pciFreeDevice(pci);
ret = virPCIDeviceFileIterate(pci, AppArmorSetSecurityPCILabel, ptr);
virPCIDeviceFree(pci);
break;
}

View File

@ -434,7 +434,7 @@ virSecurityDACRestoreSecurityImageLabel(virSecurityManagerPtr mgr,
static int
virSecurityDACSetSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
virSecurityDACSetSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
const char *file,
void *opaque)
{
@ -507,17 +507,18 @@ virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain,
dev->source.subsys.u.pci.bus,
dev->source.subsys.u.pci.slot,
dev->source.subsys.u.pci.function);
virPCIDevicePtr pci =
virPCIDeviceNew(dev->source.subsys.u.pci.domain,
dev->source.subsys.u.pci.bus,
dev->source.subsys.u.pci.slot,
dev->source.subsys.u.pci.function);
if (!pci)
goto done;
ret = pciDeviceFileIterate(pci, virSecurityDACSetSecurityPCILabel,
params);
pciFreeDevice(pci);
ret = virPCIDeviceFileIterate(pci, virSecurityDACSetSecurityPCILabel,
params);
virPCIDeviceFree(pci);
break;
}
@ -533,7 +534,7 @@ done:
static int
virSecurityDACRestoreSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
virSecurityDACRestoreSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
const char *file,
void *opaque ATTRIBUTE_UNUSED)
{
@ -586,16 +587,17 @@ virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr,
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain,
dev->source.subsys.u.pci.bus,
dev->source.subsys.u.pci.slot,
dev->source.subsys.u.pci.function);
virPCIDevicePtr pci =
virPCIDeviceNew(dev->source.subsys.u.pci.domain,
dev->source.subsys.u.pci.bus,
dev->source.subsys.u.pci.slot,
dev->source.subsys.u.pci.function);
if (!pci)
goto done;
ret = pciDeviceFileIterate(pci, virSecurityDACRestoreSecurityPCILabel, mgr);
pciFreeDevice(pci);
ret = virPCIDeviceFileIterate(pci, virSecurityDACRestoreSecurityPCILabel, mgr);
virPCIDeviceFree(pci);
break;
}

View File

@ -1159,7 +1159,7 @@ virSecuritySELinuxSetSecurityImageLabel(virSecurityManagerPtr mgr,
static int
virSecuritySELinuxSetSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
virSecuritySELinuxSetSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
const char *file, void *opaque)
{
virSecurityLabelDefPtr secdef;
@ -1213,16 +1213,17 @@ virSecuritySELinuxSetSecurityHostdevSubsysLabel(virDomainDefPtr def,
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain,
dev->source.subsys.u.pci.bus,
dev->source.subsys.u.pci.slot,
dev->source.subsys.u.pci.function);
virPCIDevicePtr pci =
virPCIDeviceNew(dev->source.subsys.u.pci.domain,
dev->source.subsys.u.pci.bus,
dev->source.subsys.u.pci.slot,
dev->source.subsys.u.pci.function);
if (!pci)
goto done;
ret = pciDeviceFileIterate(pci, virSecuritySELinuxSetSecurityPCILabel, def);
pciFreeDevice(pci);
ret = virPCIDeviceFileIterate(pci, virSecuritySELinuxSetSecurityPCILabel, def);
virPCIDeviceFree(pci);
break;
}
@ -1326,7 +1327,7 @@ virSecuritySELinuxSetSecurityHostdevLabel(virSecurityManagerPtr mgr ATTRIBUTE_UN
static int
virSecuritySELinuxRestoreSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
virSecuritySELinuxRestoreSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
const char *file,
void *opaque)
{
@ -1374,16 +1375,17 @@ virSecuritySELinuxRestoreSecurityHostdevSubsysLabel(virSecurityManagerPtr mgr,
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain,
dev->source.subsys.u.pci.bus,
dev->source.subsys.u.pci.slot,
dev->source.subsys.u.pci.function);
virPCIDevicePtr pci =
virPCIDeviceNew(dev->source.subsys.u.pci.domain,
dev->source.subsys.u.pci.bus,
dev->source.subsys.u.pci.slot,
dev->source.subsys.u.pci.function);
if (!pci)
goto done;
ret = pciDeviceFileIterate(pci, virSecuritySELinuxRestoreSecurityPCILabel, mgr);
pciFreeDevice(pci);
ret = virPCIDeviceFileIterate(pci, virSecuritySELinuxRestoreSecurityPCILabel, mgr);
virPCIDeviceFree(pci);
break;
}

View File

@ -853,8 +853,8 @@ file_iterate_hostdev_cb(usbDevice *dev ATTRIBUTE_UNUSED,
}
static int
file_iterate_pci_cb(pciDevice *dev ATTRIBUTE_UNUSED,
const char *file, void *opaque)
file_iterate_pci_cb(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
const char *file, void *opaque)
{
virBufferPtr buf = opaque;
return vah_add_file(buf, file, "rw");
@ -1022,7 +1022,7 @@ get_files(vahControl * ctl)
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
pciDevice *pci = pciGetDevice(
virPCIDevicePtr pci = virPCIDeviceNew(
dev->source.subsys.u.pci.domain,
dev->source.subsys.u.pci.bus,
dev->source.subsys.u.pci.slot,
@ -1031,8 +1031,8 @@ get_files(vahControl * ctl)
if (pci == NULL)
continue;
rc = pciDeviceFileIterate(pci, file_iterate_pci_cb, &buf);
pciFreeDevice(pci);
rc = virPCIDeviceFileIterate(pci, file_iterate_pci_cb, &buf);
virPCIDeviceFree(pci);
break;
}

View File

@ -980,7 +980,7 @@ virNetDevSysfsDeviceFile(char **pf_sysfs_device_link, const char *ifname,
int
virNetDevGetVirtualFunctions(const char *pfname,
char ***vfname,
struct pci_config_address ***virt_fns,
virPCIDeviceAddressPtr **virt_fns,
unsigned int *n_vfname)
{
int ret = -1, i;
@ -991,8 +991,8 @@ virNetDevGetVirtualFunctions(const char *pfname,
if (virNetDevSysfsFile(&pf_sysfs_device_link, pfname, "device") < 0)
return ret;
if (pciGetVirtualFunctions(pf_sysfs_device_link, virt_fns,
n_vfname) < 0)
if (virPCIGetVirtualFunctions(pf_sysfs_device_link, virt_fns,
n_vfname) < 0)
goto cleanup;
if (VIR_ALLOC_N(*vfname, *n_vfname) < 0) {
@ -1002,22 +1002,22 @@ virNetDevGetVirtualFunctions(const char *pfname,
for (i = 0; i < *n_vfname; i++)
{
if (pciGetDeviceAddrString((*virt_fns)[i]->domain,
(*virt_fns)[i]->bus,
(*virt_fns)[i]->slot,
(*virt_fns)[i]->function,
&pciConfigAddr) < 0) {
if (virPCIGetAddrString((*virt_fns)[i]->domain,
(*virt_fns)[i]->bus,
(*virt_fns)[i]->slot,
(*virt_fns)[i]->function,
&pciConfigAddr) < 0) {
virReportSystemError(ENOSYS, "%s",
_("Failed to get PCI Config Address String"));
goto cleanup;
}
if (pciSysfsFile(pciConfigAddr, &pci_sysfs_device_link) < 0) {
if (virPCIGetSysfsFile(pciConfigAddr, &pci_sysfs_device_link) < 0) {
virReportSystemError(ENOSYS, "%s",
_("Failed to get PCI SYSFS file"));
goto cleanup;
}
if (pciDeviceNetName(pci_sysfs_device_link, &((*vfname)[i])) < 0) {
if (virPCIGetNetName(pci_sysfs_device_link, &((*vfname)[i])) < 0) {
VIR_INFO("VF does not have an interface name");
}
}
@ -1053,7 +1053,7 @@ virNetDevIsVirtualFunction(const char *ifname)
if (virNetDevSysfsFile(&if_sysfs_device_link, ifname, "device") < 0)
return ret;
ret = pciDeviceIsVirtualFunction(if_sysfs_device_link);
ret = virPCIIsVirtualFunction(if_sysfs_device_link);
VIR_FREE(if_sysfs_device_link);
@ -1086,9 +1086,9 @@ virNetDevGetVirtualFunctionIndex(const char *pfname, const char *vfname,
return ret;
}
ret = pciGetVirtualFunctionIndex(pf_sysfs_device_link,
vf_sysfs_device_link,
vf_index);
ret = virPCIGetVirtualFunctionIndex(pf_sysfs_device_link,
vf_sysfs_device_link,
vf_index);
VIR_FREE(pf_sysfs_device_link);
VIR_FREE(vf_sysfs_device_link);
@ -1115,7 +1115,7 @@ virNetDevGetPhysicalFunction(const char *ifname, char **pfname)
if (virNetDevSysfsDeviceFile(&physfn_sysfs_path, ifname, "physfn") < 0)
return ret;
ret = pciDeviceNetName(physfn_sysfs_path, pfname);
ret = virPCIGetNetName(physfn_sysfs_path, pfname);
VIR_FREE(physfn_sysfs_path);
@ -1149,7 +1149,7 @@ virNetDevGetVirtualFunctionInfo(const char *vfname, char **pfname,
if (virNetDevSysfsFile(&vf_sysfs_path, vfname, "device") < 0)
goto cleanup;
ret = pciGetVirtualFunctionIndex(pf_sysfs_path, vf_sysfs_path, vf);
ret = virPCIGetVirtualFunctionIndex(pf_sysfs_path, vf_sysfs_path, vf);
cleanup:
if (ret < 0)
@ -1165,7 +1165,7 @@ cleanup:
int
virNetDevGetVirtualFunctions(const char *pfname ATTRIBUTE_UNUSED,
char ***vfname ATTRIBUTE_UNUSED,
struct pci_config_address ***virt_fns ATTRIBUTE_UNUSED,
virPCIDeviceAddressPtr **virt_fns ATTRIBUTE_UNUSED,
unsigned int *n_vfname ATTRIBUTE_UNUSED)
{
virReportSystemError(ENOSYS, "%s",

View File

@ -104,7 +104,7 @@ int virNetDevGetPhysicalFunction(const char *ifname, char **pfname)
int virNetDevGetVirtualFunctions(const char *pfname,
char ***vfname,
struct pci_config_address ***virt_fns,
virPCIDeviceAddressPtr **virt_fns,
unsigned int *n_vfname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;

File diff suppressed because it is too large Load Diff

View File

@ -26,67 +26,74 @@
# include "internal.h"
typedef struct _pciDevice pciDevice;
typedef struct _pciDeviceList pciDeviceList;
typedef struct _virPCIDevice virPCIDevice;
typedef virPCIDevice *virPCIDevicePtr;
typedef struct _virPCIDeviceAddress virPCIDeviceAddress;
typedef virPCIDeviceAddress *virPCIDeviceAddressPtr;
typedef struct _virPCIDeviceList virPCIDeviceList;
typedef virPCIDeviceList *virPCIDeviceListPtr;
struct pci_config_address {
struct _virPCIDeviceAddress {
unsigned int domain;
unsigned int bus;
unsigned int slot;
unsigned int function;
};
pciDevice *pciGetDevice (unsigned domain,
unsigned bus,
unsigned slot,
unsigned function);
void pciFreeDevice (pciDevice *dev);
const char *pciDeviceGetName (pciDevice *dev);
int pciDettachDevice (pciDevice *dev,
pciDeviceList *activeDevs,
pciDeviceList *inactiveDevs,
const char *driver);
int pciReAttachDevice (pciDevice *dev,
pciDeviceList *activeDevs,
pciDeviceList *inactiveDevs,
const char *driver);
int pciResetDevice (pciDevice *dev,
pciDeviceList *activeDevs,
pciDeviceList *inactiveDevs);
void pciDeviceSetManaged(pciDevice *dev,
unsigned managed);
unsigned pciDeviceGetManaged(pciDevice *dev);
void pciDeviceSetUsedBy(pciDevice *dev,
const char *used_by);
const char *pciDeviceGetUsedBy(pciDevice *dev);
unsigned pciDeviceGetUnbindFromStub(pciDevice *dev);
void pciDeviceSetUnbindFromStub(pciDevice *dev,
unsigned unbind);
unsigned pciDeviceGetRemoveSlot(pciDevice *dev);
void pciDeviceSetRemoveSlot(pciDevice *dev,
unsigned remove_slot);
unsigned pciDeviceGetReprobe(pciDevice *dev);
void pciDeviceSetReprobe(pciDevice *dev,
unsigned reprobe);
void pciDeviceReAttachInit(pciDevice *dev);
virPCIDevicePtr virPCIDeviceNew(unsigned domain,
unsigned bus,
unsigned slot,
unsigned function);
void virPCIDeviceFree(virPCIDevicePtr dev);
const char *virPCIDeviceGetName(virPCIDevicePtr dev);
pciDeviceList *pciDeviceListNew (void);
void pciDeviceListFree (pciDeviceList *list);
int pciDeviceListAdd (pciDeviceList *list,
pciDevice *dev);
pciDevice * pciDeviceListGet (pciDeviceList *list,
int idx);
int pciDeviceListCount (pciDeviceList *list);
pciDevice * pciDeviceListSteal (pciDeviceList *list,
pciDevice *dev);
pciDevice * pciDeviceListStealIndex(pciDeviceList *list,
int idx);
void pciDeviceListDel (pciDeviceList *list,
pciDevice *dev);
pciDevice * pciDeviceListFind (pciDeviceList *list,
pciDevice *dev);
int pciDeviceListFindIndex(pciDeviceList *list,
pciDevice *dev);
int virPCIDeviceDetach(virPCIDevicePtr dev,
virPCIDeviceListPtr activeDevs,
virPCIDeviceListPtr inactiveDevs,
const char *driver);
int virPCIDeviceReattach(virPCIDevicePtr dev,
virPCIDeviceListPtr activeDevs,
virPCIDeviceListPtr inactiveDevs,
const char *driver);
int virPCIDeviceReset(virPCIDevicePtr dev,
virPCIDeviceListPtr activeDevs,
virPCIDeviceListPtr inactiveDevs);
void virPCIDeviceSetManaged(virPCIDevice *dev,
unsigned managed);
unsigned virPCIDeviceGetManaged(virPCIDevice *dev);
void virPCIDeviceSetUsedBy(virPCIDevice *dev,
const char *used_by);
const char *virPCIDeviceGetUsedBy(virPCIDevice *dev);
unsigned virPCIDeviceGetUnbindFromStub(virPCIDevicePtr dev);
void virPCIDeviceSetUnbindFromStub(virPCIDevice *dev,
unsigned unbind);
unsigned virPCIDeviceGetRemoveSlot(virPCIDevicePtr dev);
void virPCIDeviceSetRemoveSlot(virPCIDevice *dev,
unsigned remove_slot);
unsigned virPCIDeviceGetReprobe(virPCIDevicePtr dev);
void virPCIDeviceSetReprobe(virPCIDevice *dev,
unsigned reprobe);
void virPCIDeviceReattachInit(virPCIDevice *dev);
virPCIDeviceListPtr virPCIDeviceListNew(void);
void virPCIDeviceListFree(virPCIDeviceListPtr list);
int virPCIDeviceListAdd(virPCIDeviceListPtr list,
virPCIDevicePtr dev);
virPCIDevicePtr virPCIDeviceListGet(virPCIDeviceListPtr list,
int idx);
int virPCIDeviceListCount(virPCIDeviceListPtr list);
virPCIDevicePtr virPCIDeviceListSteal(virPCIDeviceListPtr list,
virPCIDevicePtr dev);
virPCIDevicePtr virPCIDeviceListStealIndex(virPCIDeviceListPtr list,
int idx);
void virPCIDeviceListDel(virPCIDeviceListPtr list,
virPCIDevicePtr dev);
virPCIDevicePtr virPCIDeviceListFind(virPCIDeviceListPtr list,
virPCIDevicePtr dev);
int virPCIDeviceListFindIndex(virPCIDeviceListPtr list,
virPCIDevicePtr dev);
/*
* Callback that will be invoked once for each file
@ -95,46 +102,47 @@ int pciDeviceListFindIndex(pciDeviceList *list,
* Should return 0 if successfully processed, or
* -1 to indicate error and abort iteration
*/
typedef int (*pciDeviceFileActor)(pciDevice *dev,
const char *path, void *opaque);
typedef int (*virPCIDeviceFileActor)(virPCIDevicePtr dev,
const char *path, void *opaque);
int pciDeviceFileIterate(pciDevice *dev,
pciDeviceFileActor actor,
void *opaque);
int virPCIDeviceFileIterate(virPCIDevicePtr dev,
virPCIDeviceFileActor actor,
void *opaque);
int pciDeviceIsAssignable(pciDevice *dev,
int strict_acs_check);
int pciWaitForDeviceCleanup(pciDevice *dev, const char *matcher);
int virPCIDeviceIsAssignable(virPCIDevicePtr dev,
int strict_acs_check);
int virPCIDeviceWaitForCleanup(virPCIDevicePtr dev, const char *matcher);
int pciGetPhysicalFunction(const char *sysfs_path,
struct pci_config_address **phys_fn);
int virPCIGetPhysicalFunction(const char *sysfs_path,
virPCIDeviceAddressPtr *phys_fn);
int pciGetVirtualFunctions(const char *sysfs_path,
struct pci_config_address ***virtual_functions,
unsigned int *num_virtual_functions);
int virPCIGetVirtualFunctions(const char *sysfs_path,
virPCIDeviceAddressPtr **virtual_functions,
unsigned int *num_virtual_functions);
int pciDeviceIsVirtualFunction(const char *vf_sysfs_device_link);
int virPCIIsVirtualFunction(const char *vf_sysfs_device_link);
int pciGetVirtualFunctionIndex(const char *pf_sysfs_device_link,
const char *vf_sysfs_device_link,
int *vf_index);
int virPCIGetVirtualFunctionIndex(const char *pf_sysfs_device_link,
const char *vf_sysfs_device_link,
int *vf_index);
int pciConfigAddressToSysfsFile(struct pci_config_address *dev,
char **pci_sysfs_device_link);
int virPCIDeviceAddressGetSysfsFile(virPCIDeviceAddressPtr dev,
char **pci_sysfs_device_link);
int pciDeviceNetName(char *device_link_sysfs_path, char **netname);
int virPCIGetNetName(char *device_link_sysfs_path, char **netname);
int pciSysfsFile(char *pciDeviceName, char **pci_sysfs_device_link)
int virPCIGetSysfsFile(char *virPCIDeviceName,
char **pci_sysfs_device_link)
ATTRIBUTE_RETURN_CHECK;
int pciGetDeviceAddrString(unsigned domain,
unsigned bus,
unsigned slot,
unsigned function,
char **pciConfigAddr)
int virPCIGetAddrString(unsigned domain,
unsigned bus,
unsigned slot,
unsigned function,
char **pciConfigAddr)
ATTRIBUTE_NONNULL(5) ATTRIBUTE_RETURN_CHECK;
int pciDeviceGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
char **pfname, int *vf_index);
int virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
char **pfname, int *vf_index);
#endif /* __VIR_PCI_H__ */

View File

@ -2102,23 +2102,23 @@ out:
static int
xenUnifiedNodeDeviceDettach(virNodeDevicePtr dev)
{
pciDevice *pci;
virPCIDevicePtr pci;
unsigned domain, bus, slot, function;
int ret = -1;
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
return -1;
pci = pciGetDevice(domain, bus, slot, function);
pci = virPCIDeviceNew(domain, bus, slot, function);
if (!pci)
return -1;
if (pciDettachDevice(pci, NULL, NULL, "pciback") < 0)
if (virPCIDeviceDetach(pci, NULL, NULL, "pciback") < 0)
goto out;
ret = 0;
out:
pciFreeDevice(pci);
virPCIDeviceFree(pci);
return ret;
}
@ -2183,7 +2183,7 @@ out:
static int
xenUnifiedNodeDeviceReAttach(virNodeDevicePtr dev)
{
pciDevice *pci;
virPCIDevicePtr pci;
unsigned domain, bus, slot, function;
int ret = -1;
int domid;
@ -2191,7 +2191,7 @@ xenUnifiedNodeDeviceReAttach(virNodeDevicePtr dev)
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
return -1;
pci = pciGetDevice(domain, bus, slot, function);
pci = virPCIDeviceNew(domain, bus, slot, function);
if (!pci)
return -1;
@ -2203,35 +2203,35 @@ xenUnifiedNodeDeviceReAttach(virNodeDevicePtr dev)
goto out;
}
if (pciReAttachDevice(pci, NULL, NULL, "pciback") < 0)
if (virPCIDeviceReattach(pci, NULL, NULL, "pciback") < 0)
goto out;
ret = 0;
out:
pciFreeDevice(pci);
virPCIDeviceFree(pci);
return ret;
}
static int
xenUnifiedNodeDeviceReset(virNodeDevicePtr dev)
{
pciDevice *pci;
virPCIDevicePtr pci;
unsigned domain, bus, slot, function;
int ret = -1;
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
return -1;
pci = pciGetDevice(domain, bus, slot, function);
pci = virPCIDeviceNew(domain, bus, slot, function);
if (!pci)
return -1;
if (pciResetDevice(pci, NULL, NULL) < 0)
if (virPCIDeviceReset(pci, NULL, NULL) < 0)
goto out;
ret = 0;
out:
pciFreeDevice(pci);
virPCIDeviceFree(pci);
return ret;
}