mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 07:05:28 +00:00
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:
parent
b46f7f4a0b
commit
202535601c
@ -36,7 +36,6 @@
|
|||||||
#include "virutil.h"
|
#include "virutil.h"
|
||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
#include "viruuid.h"
|
#include "viruuid.h"
|
||||||
#include "virpci.h"
|
|
||||||
#include "virrandom.h"
|
#include "virrandom.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NODEDEV
|
#define VIR_FROM_THIS VIR_FROM_NODEDEV
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
# include "internal.h"
|
# include "internal.h"
|
||||||
# include "virutil.h"
|
# include "virutil.h"
|
||||||
# include "virthread.h"
|
# include "virthread.h"
|
||||||
|
# include "virpci.h"
|
||||||
|
|
||||||
# include <libxml/tree.h>
|
# include <libxml/tree.h>
|
||||||
|
|
||||||
@ -111,8 +112,8 @@ struct _virNodeDevCapsDef {
|
|||||||
unsigned int class;
|
unsigned int class;
|
||||||
char *product_name;
|
char *product_name;
|
||||||
char *vendor_name;
|
char *vendor_name;
|
||||||
struct pci_config_address *physical_function;
|
virPCIDeviceAddressPtr physical_function;
|
||||||
struct pci_config_address **virtual_functions;
|
virPCIDeviceAddressPtr *virtual_functions;
|
||||||
unsigned int num_virtual_functions;
|
unsigned int num_virtual_functions;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
} pci_dev;
|
} pci_dev;
|
||||||
|
@ -992,43 +992,43 @@ virNWFilterVarValueGetSimple;
|
|||||||
|
|
||||||
|
|
||||||
# pci.h
|
# pci.h
|
||||||
pciConfigAddressToSysfsFile;
|
virPCIDeviceAddressGetSysfsFile;
|
||||||
pciDettachDevice;
|
virPCIDeviceDetach;
|
||||||
pciDeviceFileIterate;
|
virPCIDeviceFileIterate;
|
||||||
pciDeviceGetManaged;
|
virPCIDeviceFree;
|
||||||
pciDeviceGetName;
|
virPCIDeviceGetManaged;
|
||||||
pciDeviceGetRemoveSlot;
|
virPCIDeviceGetName;
|
||||||
pciDeviceGetReprobe;
|
virPCIDeviceGetRemoveSlot;
|
||||||
pciDeviceGetUnbindFromStub;
|
virPCIDeviceGetReprobe;
|
||||||
pciDeviceGetUsedBy;
|
virPCIDeviceGetUnbindFromStub;
|
||||||
pciDeviceGetVirtualFunctionInfo;
|
virPCIDeviceGetUsedBy;
|
||||||
pciDeviceIsAssignable;
|
virPCIDeviceIsAssignable;
|
||||||
pciDeviceIsVirtualFunction;
|
virPCIDeviceListAdd;
|
||||||
pciDeviceListAdd;
|
virPCIDeviceListCount;
|
||||||
pciDeviceListCount;
|
virPCIDeviceListDel;
|
||||||
pciDeviceListDel;
|
virPCIDeviceListFind;
|
||||||
pciDeviceListFind;
|
virPCIDeviceListFindIndex;
|
||||||
pciDeviceListFindIndex;
|
virPCIDeviceListFree;
|
||||||
pciDeviceListFree;
|
virPCIDeviceListGet;
|
||||||
pciDeviceListGet;
|
virPCIDeviceListNew;
|
||||||
pciDeviceListNew;
|
virPCIDeviceListSteal;
|
||||||
pciDeviceListSteal;
|
virPCIDeviceListStealIndex;
|
||||||
pciDeviceListStealIndex;
|
virPCIDeviceNew;
|
||||||
pciDeviceNetName;
|
virPCIDeviceReattach;
|
||||||
pciDeviceReAttachInit;
|
virPCIDeviceReattachInit;
|
||||||
pciDeviceSetManaged;
|
virPCIDeviceReset;
|
||||||
pciDeviceSetRemoveSlot;
|
virPCIDeviceSetManaged;
|
||||||
pciDeviceSetReprobe;
|
virPCIDeviceSetRemoveSlot;
|
||||||
pciDeviceSetUnbindFromStub;
|
virPCIDeviceSetReprobe;
|
||||||
pciDeviceSetUsedBy;
|
virPCIDeviceSetUnbindFromStub;
|
||||||
pciFreeDevice;
|
virPCIDeviceSetUsedBy;
|
||||||
pciGetDevice;
|
virPCIDeviceWaitForCleanup;
|
||||||
pciGetPhysicalFunction;
|
virPCIGetNetName;
|
||||||
pciGetVirtualFunctionIndex;
|
virPCIGetPhysicalFunction;
|
||||||
pciGetVirtualFunctions;
|
virPCIGetVirtualFunctionIndex;
|
||||||
pciReAttachDevice;
|
virPCIGetVirtualFunctionInfo;
|
||||||
pciResetDevice;
|
virPCIGetVirtualFunctions;
|
||||||
pciWaitForDeviceCleanup;
|
virPCIIsVirtualFunction;
|
||||||
|
|
||||||
|
|
||||||
# secret_conf.h
|
# secret_conf.h
|
||||||
|
@ -3622,7 +3622,7 @@ static int
|
|||||||
networkCreateInterfacePool(virNetworkDefPtr netdef) {
|
networkCreateInterfacePool(virNetworkDefPtr netdef) {
|
||||||
unsigned int num_virt_fns = 0;
|
unsigned int num_virt_fns = 0;
|
||||||
char **vfname = NULL;
|
char **vfname = NULL;
|
||||||
struct pci_config_address **virt_fns;
|
virPCIDeviceAddressPtr *virt_fns;
|
||||||
int ret = -1, ii = 0;
|
int ret = -1, ii = 0;
|
||||||
|
|
||||||
if ((virNetDevGetVirtualFunctions(netdef->forward.pfs->dev,
|
if ((virNetDevGetVirtualFunctions(netdef->forward.pfs->dev,
|
||||||
|
@ -481,10 +481,10 @@ static int udevProcessPCI(struct udev_device *device,
|
|||||||
goto out;
|
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;
|
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) ||
|
||||||
data->pci_dev.num_virtual_functions > 0)
|
data->pci_dev.num_virtual_functions > 0)
|
||||||
data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
|
data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include "qemu_agent.h"
|
#include "qemu_agent.h"
|
||||||
#include "qemu_command.h"
|
|
||||||
#include "viralloc.h"
|
#include "viralloc.h"
|
||||||
#include "virlog.h"
|
#include "virlog.h"
|
||||||
#include "virerror.h"
|
#include "virerror.h"
|
||||||
|
@ -181,11 +181,10 @@ struct _virQEMUDriver {
|
|||||||
|
|
||||||
virSecurityManagerPtr securityManager;
|
virSecurityManagerPtr securityManager;
|
||||||
|
|
||||||
pciDeviceList *activePciHostdevs;
|
virPCIDeviceListPtr activePciHostdevs;
|
||||||
|
virPCIDeviceListPtr inactivePciHostdevs;
|
||||||
usbDeviceList *activeUsbHostdevs;
|
usbDeviceList *activeUsbHostdevs;
|
||||||
|
|
||||||
pciDeviceList *inactivePciHostdevs;
|
|
||||||
|
|
||||||
virHashTablePtr sharedDisks;
|
virHashTablePtr sharedDisks;
|
||||||
|
|
||||||
virPortAllocatorPtr remotePorts;
|
virPortAllocatorPtr remotePorts;
|
||||||
|
@ -774,13 +774,13 @@ qemuStartup(bool privileged,
|
|||||||
if (qemuSecurityInit(qemu_driver) < 0)
|
if (qemuSecurityInit(qemu_driver) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if ((qemu_driver->activePciHostdevs = pciDeviceListNew()) == NULL)
|
if ((qemu_driver->activePciHostdevs = virPCIDeviceListNew()) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if ((qemu_driver->activeUsbHostdevs = usbDeviceListNew()) == NULL)
|
if ((qemu_driver->activeUsbHostdevs = usbDeviceListNew()) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if ((qemu_driver->inactivePciHostdevs = pciDeviceListNew()) == NULL)
|
if ((qemu_driver->inactivePciHostdevs = virPCIDeviceListNew()) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!(qemu_driver->sharedDisks = virHashCreate(30, NULL)))
|
if (!(qemu_driver->sharedDisks = virHashCreate(30, NULL)))
|
||||||
@ -1047,8 +1047,8 @@ qemuShutdown(void) {
|
|||||||
|
|
||||||
qemuDriverLock(qemu_driver);
|
qemuDriverLock(qemu_driver);
|
||||||
virNWFilterUnRegisterCallbackDriver(&qemuCallbackDriver);
|
virNWFilterUnRegisterCallbackDriver(&qemuCallbackDriver);
|
||||||
pciDeviceListFree(qemu_driver->activePciHostdevs);
|
virPCIDeviceListFree(qemu_driver->activePciHostdevs);
|
||||||
pciDeviceListFree(qemu_driver->inactivePciHostdevs);
|
virPCIDeviceListFree(qemu_driver->inactivePciHostdevs);
|
||||||
usbDeviceListFree(qemu_driver->activeUsbHostdevs);
|
usbDeviceListFree(qemu_driver->activeUsbHostdevs);
|
||||||
virHashFree(qemu_driver->sharedDisks);
|
virHashFree(qemu_driver->sharedDisks);
|
||||||
virCapabilitiesFree(qemu_driver->caps);
|
virCapabilitiesFree(qemu_driver->caps);
|
||||||
@ -10021,7 +10021,7 @@ static int
|
|||||||
qemuNodeDeviceDettach(virNodeDevicePtr dev)
|
qemuNodeDeviceDettach(virNodeDevicePtr dev)
|
||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = dev->conn->privateData;
|
virQEMUDriverPtr driver = dev->conn->privateData;
|
||||||
pciDevice *pci;
|
virPCIDevicePtr pci;
|
||||||
unsigned domain, bus, slot, function;
|
unsigned domain, bus, slot, function;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
bool in_inactive_list = false;
|
bool in_inactive_list = false;
|
||||||
@ -10029,14 +10029,14 @@ qemuNodeDeviceDettach(virNodeDevicePtr dev)
|
|||||||
if (qemuNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
if (qemuNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pci = pciGetDevice(domain, bus, slot, function);
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
||||||
if (!pci)
|
if (!pci)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
in_inactive_list = pciDeviceListFind(driver->inactivePciHostdevs, pci);
|
in_inactive_list = virPCIDeviceListFind(driver->inactivePciHostdevs, pci);
|
||||||
|
|
||||||
if (pciDettachDevice(pci, driver->activePciHostdevs,
|
if (virPCIDeviceDetach(pci, driver->activePciHostdevs,
|
||||||
driver->inactivePciHostdevs, "pci-stub") < 0)
|
driver->inactivePciHostdevs, "pci-stub") < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -10044,7 +10044,7 @@ qemuNodeDeviceDettach(virNodeDevicePtr dev)
|
|||||||
out:
|
out:
|
||||||
qemuDriverUnlock(driver);
|
qemuDriverUnlock(driver);
|
||||||
if (in_inactive_list)
|
if (in_inactive_list)
|
||||||
pciFreeDevice(pci);
|
virPCIDeviceFree(pci);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10052,43 +10052,43 @@ static int
|
|||||||
qemuNodeDeviceReAttach(virNodeDevicePtr dev)
|
qemuNodeDeviceReAttach(virNodeDevicePtr dev)
|
||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = dev->conn->privateData;
|
virQEMUDriverPtr driver = dev->conn->privateData;
|
||||||
pciDevice *pci;
|
virPCIDevicePtr pci;
|
||||||
pciDevice *other;
|
virPCIDevicePtr other;
|
||||||
unsigned domain, bus, slot, function;
|
unsigned domain, bus, slot, function;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (qemuNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
if (qemuNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pci = pciGetDevice(domain, bus, slot, function);
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
||||||
if (!pci)
|
if (!pci)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
other = pciDeviceListFind(driver->activePciHostdevs, pci);
|
other = virPCIDeviceListFind(driver->activePciHostdevs, pci);
|
||||||
if (other) {
|
if (other) {
|
||||||
const char *other_name = pciDeviceGetUsedBy(other);
|
const char *other_name = virPCIDeviceGetUsedBy(other);
|
||||||
|
|
||||||
if (other_name)
|
if (other_name)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
_("PCI device %s is still in use by domain %s"),
|
_("PCI device %s is still in use by domain %s"),
|
||||||
pciDeviceGetName(pci), other_name);
|
virPCIDeviceGetName(pci), other_name);
|
||||||
else
|
else
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
_("PCI device %s is still in use"),
|
_("PCI device %s is still in use"),
|
||||||
pciDeviceGetName(pci));
|
virPCIDeviceGetName(pci));
|
||||||
}
|
}
|
||||||
|
|
||||||
pciDeviceReAttachInit(pci);
|
virPCIDeviceReattachInit(pci);
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
if (pciReAttachDevice(pci, driver->activePciHostdevs,
|
if (virPCIDeviceReattach(pci, driver->activePciHostdevs,
|
||||||
driver->inactivePciHostdevs, "pci-stub") < 0)
|
driver->inactivePciHostdevs, "pci-stub") < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
out:
|
out:
|
||||||
qemuDriverUnlock(driver);
|
qemuDriverUnlock(driver);
|
||||||
pciFreeDevice(pci);
|
virPCIDeviceFree(pci);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10096,27 +10096,27 @@ static int
|
|||||||
qemuNodeDeviceReset(virNodeDevicePtr dev)
|
qemuNodeDeviceReset(virNodeDevicePtr dev)
|
||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = dev->conn->privateData;
|
virQEMUDriverPtr driver = dev->conn->privateData;
|
||||||
pciDevice *pci;
|
virPCIDevicePtr pci;
|
||||||
unsigned domain, bus, slot, function;
|
unsigned domain, bus, slot, function;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (qemuNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
if (qemuNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pci = pciGetDevice(domain, bus, slot, function);
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
||||||
if (!pci)
|
if (!pci)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
|
|
||||||
if (pciResetDevice(pci, driver->activePciHostdevs,
|
if (virPCIDeviceReset(pci, driver->activePciHostdevs,
|
||||||
driver->inactivePciHostdevs) < 0)
|
driver->inactivePciHostdevs) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
out:
|
out:
|
||||||
qemuDriverUnlock(driver);
|
qemuDriverUnlock(driver);
|
||||||
pciFreeDevice(pci);
|
virPCIDeviceFree(pci);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,84 +33,84 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||||
|
|
||||||
static pciDeviceList *
|
static virPCIDeviceListPtr
|
||||||
qemuGetPciHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
|
qemuGetPciHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
|
||||||
{
|
{
|
||||||
pciDeviceList *list;
|
virPCIDeviceListPtr list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!(list = pciDeviceListNew()))
|
if (!(list = virPCIDeviceListNew()))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0 ; i < nhostdevs ; i++) {
|
for (i = 0 ; i < nhostdevs ; i++) {
|
||||||
virDomainHostdevDefPtr hostdev = hostdevs[i];
|
virDomainHostdevDefPtr hostdev = hostdevs[i];
|
||||||
pciDevice *dev;
|
virPCIDevicePtr dev;
|
||||||
|
|
||||||
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
||||||
continue;
|
continue;
|
||||||
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dev = pciGetDevice(hostdev->source.subsys.u.pci.domain,
|
dev = virPCIDeviceNew(hostdev->source.subsys.u.pci.domain,
|
||||||
hostdev->source.subsys.u.pci.bus,
|
hostdev->source.subsys.u.pci.bus,
|
||||||
hostdev->source.subsys.u.pci.slot,
|
hostdev->source.subsys.u.pci.slot,
|
||||||
hostdev->source.subsys.u.pci.function);
|
hostdev->source.subsys.u.pci.function);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
pciDeviceListFree(list);
|
virPCIDeviceListFree(list);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pciDeviceListAdd(list, dev) < 0) {
|
if (virPCIDeviceListAdd(list, dev) < 0) {
|
||||||
pciFreeDevice(dev);
|
virPCIDeviceFree(dev);
|
||||||
pciDeviceListFree(list);
|
virPCIDeviceListFree(list);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pciDeviceSetManaged(dev, hostdev->managed);
|
virPCIDeviceSetManaged(dev, hostdev->managed);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pciDeviceList *
|
static virPCIDeviceListPtr
|
||||||
qemuGetActivePciHostDeviceList(virQEMUDriverPtr driver,
|
qemuGetActivePciHostDeviceList(virQEMUDriverPtr driver,
|
||||||
virDomainHostdevDefPtr *hostdevs,
|
virDomainHostdevDefPtr *hostdevs,
|
||||||
int nhostdevs)
|
int nhostdevs)
|
||||||
{
|
{
|
||||||
pciDeviceList *list;
|
virPCIDeviceListPtr list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!(list = pciDeviceListNew()))
|
if (!(list = virPCIDeviceListNew()))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0 ; i < nhostdevs ; i++) {
|
for (i = 0 ; i < nhostdevs ; i++) {
|
||||||
virDomainHostdevDefPtr hostdev = hostdevs[i];
|
virDomainHostdevDefPtr hostdev = hostdevs[i];
|
||||||
pciDevice *dev;
|
virPCIDevicePtr dev;
|
||||||
pciDevice *activeDev;
|
virPCIDevicePtr activeDev;
|
||||||
|
|
||||||
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
||||||
continue;
|
continue;
|
||||||
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dev = pciGetDevice(hostdev->source.subsys.u.pci.domain,
|
dev = virPCIDeviceNew(hostdev->source.subsys.u.pci.domain,
|
||||||
hostdev->source.subsys.u.pci.bus,
|
hostdev->source.subsys.u.pci.bus,
|
||||||
hostdev->source.subsys.u.pci.slot,
|
hostdev->source.subsys.u.pci.slot,
|
||||||
hostdev->source.subsys.u.pci.function);
|
hostdev->source.subsys.u.pci.function);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
pciDeviceListFree(list);
|
virPCIDeviceListFree(list);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((activeDev = pciDeviceListFind(driver->activePciHostdevs, dev))) {
|
if ((activeDev = virPCIDeviceListFind(driver->activePciHostdevs, dev))) {
|
||||||
if (pciDeviceListAdd(list, activeDev) < 0) {
|
if (virPCIDeviceListAdd(list, activeDev) < 0) {
|
||||||
pciFreeDevice(dev);
|
virPCIDeviceFree(dev);
|
||||||
pciDeviceListFree(list);
|
virPCIDeviceListFree(list);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pciFreeDevice(dev);
|
virPCIDeviceFree(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@ -126,7 +126,7 @@ int qemuUpdateActivePciHostdevs(virQEMUDriverPtr driver,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < def->nhostdevs; i++) {
|
for (i = 0; i < def->nhostdevs; i++) {
|
||||||
pciDevice *dev = NULL;
|
virPCIDevicePtr dev = NULL;
|
||||||
hostdev = def->hostdevs[i];
|
hostdev = def->hostdevs[i];
|
||||||
|
|
||||||
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
||||||
@ -134,7 +134,7 @@ int qemuUpdateActivePciHostdevs(virQEMUDriverPtr driver,
|
|||||||
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dev = pciGetDevice(hostdev->source.subsys.u.pci.domain,
|
dev = virPCIDeviceNew(hostdev->source.subsys.u.pci.domain,
|
||||||
hostdev->source.subsys.u.pci.bus,
|
hostdev->source.subsys.u.pci.bus,
|
||||||
hostdev->source.subsys.u.pci.slot,
|
hostdev->source.subsys.u.pci.slot,
|
||||||
hostdev->source.subsys.u.pci.function);
|
hostdev->source.subsys.u.pci.function);
|
||||||
@ -142,16 +142,16 @@ int qemuUpdateActivePciHostdevs(virQEMUDriverPtr driver,
|
|||||||
if (!dev)
|
if (!dev)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pciDeviceSetManaged(dev, hostdev->managed);
|
virPCIDeviceSetManaged(dev, hostdev->managed);
|
||||||
pciDeviceSetUsedBy(dev, def->name);
|
virPCIDeviceSetUsedBy(dev, def->name);
|
||||||
|
|
||||||
/* Setup the original states for the PCI device */
|
/* Setup the original states for the PCI device */
|
||||||
pciDeviceSetUnbindFromStub(dev, hostdev->origstates.states.pci.unbind_from_stub);
|
virPCIDeviceSetUnbindFromStub(dev, hostdev->origstates.states.pci.unbind_from_stub);
|
||||||
pciDeviceSetRemoveSlot(dev, hostdev->origstates.states.pci.remove_slot);
|
virPCIDeviceSetRemoveSlot(dev, hostdev->origstates.states.pci.remove_slot);
|
||||||
pciDeviceSetReprobe(dev, hostdev->origstates.states.pci.reprobe);
|
virPCIDeviceSetReprobe(dev, hostdev->origstates.states.pci.reprobe);
|
||||||
|
|
||||||
if (pciDeviceListAdd(driver->activePciHostdevs, dev) < 0) {
|
if (virPCIDeviceListAdd(driver->activePciHostdevs, dev) < 0) {
|
||||||
pciFreeDevice(dev);
|
virPCIDeviceFree(dev);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,14 +203,14 @@ qemuUpdateActiveUsbHostdevs(virQEMUDriverPtr driver,
|
|||||||
static int
|
static int
|
||||||
qemuDomainHostdevPciSysfsPath(virDomainHostdevDefPtr hostdev, char **sysfs_path)
|
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.domain = hostdev->source.subsys.u.pci.domain;
|
||||||
config_address.bus = hostdev->source.subsys.u.pci.bus;
|
config_address.bus = hostdev->source.subsys.u.pci.bus;
|
||||||
config_address.slot = hostdev->source.subsys.u.pci.slot;
|
config_address.slot = hostdev->source.subsys.u.pci.slot;
|
||||||
config_address.function = hostdev->source.subsys.u.pci.function;
|
config_address.function = hostdev->source.subsys.u.pci.function;
|
||||||
|
|
||||||
return pciConfigAddressToSysfsFile(&config_address, sysfs_path);
|
return virPCIDeviceAddressGetSysfsFile(&config_address, sysfs_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -222,7 +222,7 @@ qemuDomainHostdevIsVirtualFunction(virDomainHostdevDefPtr hostdev)
|
|||||||
if (qemuDomainHostdevPciSysfsPath(hostdev, &sysfs_path) < 0)
|
if (qemuDomainHostdevPciSysfsPath(hostdev, &sysfs_path) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = pciDeviceIsVirtualFunction(sysfs_path);
|
ret = virPCIIsVirtualFunction(sysfs_path);
|
||||||
|
|
||||||
VIR_FREE(sysfs_path);
|
VIR_FREE(sysfs_path);
|
||||||
|
|
||||||
@ -239,12 +239,12 @@ qemuDomainHostdevNetDevice(virDomainHostdevDefPtr hostdev, char **linkdev,
|
|||||||
if (qemuDomainHostdevPciSysfsPath(hostdev, &sysfs_path) < 0)
|
if (qemuDomainHostdevPciSysfsPath(hostdev, &sysfs_path) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (pciDeviceIsVirtualFunction(sysfs_path) == 1) {
|
if (virPCIIsVirtualFunction(sysfs_path) == 1) {
|
||||||
if (pciDeviceGetVirtualFunctionInfo(sysfs_path, linkdev,
|
if (virPCIGetVirtualFunctionInfo(sysfs_path, linkdev,
|
||||||
vf) < 0)
|
vf) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
if (pciDeviceNetName(sysfs_path, linkdev) < 0)
|
if (virPCIGetNetName(sysfs_path, linkdev) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
*vf = -1;
|
*vf = -1;
|
||||||
}
|
}
|
||||||
@ -406,7 +406,7 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
|
|||||||
virDomainHostdevDefPtr *hostdevs,
|
virDomainHostdevDefPtr *hostdevs,
|
||||||
int nhostdevs)
|
int nhostdevs)
|
||||||
{
|
{
|
||||||
pciDeviceList *pcidevs;
|
virPCIDeviceListPtr pcidevs;
|
||||||
int last_processed_hostdev_vf = -1;
|
int last_processed_hostdev_vf = -1;
|
||||||
int i;
|
int i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -427,47 +427,47 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
|
|||||||
* to pci-stub.ko
|
* to pci-stub.ko
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
|
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
|
||||||
pciDevice *dev = pciDeviceListGet(pcidevs, i);
|
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
|
||||||
pciDevice *other;
|
virPCIDevicePtr other;
|
||||||
|
|
||||||
if (!pciDeviceIsAssignable(dev, !cfg->relaxedACS)) {
|
if (!virPCIDeviceIsAssignable(dev, !cfg->relaxedACS)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
_("PCI device %s is not assignable"),
|
_("PCI device %s is not assignable"),
|
||||||
pciDeviceGetName(dev));
|
virPCIDeviceGetName(dev));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
/* The device is in use by other active domain if
|
/* The device is in use by other active domain if
|
||||||
* the dev is in list driver->activePciHostdevs.
|
* the dev is in list driver->activePciHostdevs.
|
||||||
*/
|
*/
|
||||||
if ((other = pciDeviceListFind(driver->activePciHostdevs, dev))) {
|
if ((other = virPCIDeviceListFind(driver->activePciHostdevs, dev))) {
|
||||||
const char *other_name = pciDeviceGetUsedBy(other);
|
const char *other_name = virPCIDeviceGetUsedBy(other);
|
||||||
|
|
||||||
if (other_name)
|
if (other_name)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
_("PCI device %s is in use by domain %s"),
|
_("PCI device %s is in use by domain %s"),
|
||||||
pciDeviceGetName(dev), other_name);
|
virPCIDeviceGetName(dev), other_name);
|
||||||
else
|
else
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
_("PCI device %s is already in use"),
|
_("PCI device %s is already in use"),
|
||||||
pciDeviceGetName(dev));
|
virPCIDeviceGetName(dev));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loop 2: detach managed devices */
|
/* Loop 2: detach managed devices */
|
||||||
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
|
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
|
||||||
pciDevice *dev = pciDeviceListGet(pcidevs, i);
|
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
|
||||||
if (pciDeviceGetManaged(dev) &&
|
if (virPCIDeviceGetManaged(dev) &&
|
||||||
pciDettachDevice(dev, driver->activePciHostdevs, NULL, "pci-stub") < 0)
|
virPCIDeviceDetach(dev, driver->activePciHostdevs, NULL, "pci-stub") < 0)
|
||||||
goto reattachdevs;
|
goto reattachdevs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loop 3: Now that all the PCI hostdevs have been detached, we
|
/* Loop 3: Now that all the PCI hostdevs have been detached, we
|
||||||
* can safely reset them */
|
* can safely reset them */
|
||||||
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
|
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
|
||||||
pciDevice *dev = pciDeviceListGet(pcidevs, i);
|
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
|
||||||
if (pciResetDevice(dev, driver->activePciHostdevs,
|
if (virPCIDeviceReset(dev, driver->activePciHostdevs,
|
||||||
driver->inactivePciHostdevs) < 0)
|
driver->inactivePciHostdevs) < 0)
|
||||||
goto reattachdevs;
|
goto reattachdevs;
|
||||||
}
|
}
|
||||||
@ -491,35 +491,35 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Loop 5: Now mark all the devices as active */
|
/* Loop 5: Now mark all the devices as active */
|
||||||
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
|
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
|
||||||
pciDevice *dev = pciDeviceListGet(pcidevs, i);
|
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
|
||||||
if (pciDeviceListAdd(driver->activePciHostdevs, dev) < 0)
|
if (virPCIDeviceListAdd(driver->activePciHostdevs, dev) < 0)
|
||||||
goto inactivedevs;
|
goto inactivedevs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loop 6: Now remove the devices from inactive list. */
|
/* Loop 6: Now remove the devices from inactive list. */
|
||||||
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
|
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
|
||||||
pciDevice *dev = pciDeviceListGet(pcidevs, i);
|
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
|
||||||
pciDeviceListDel(driver->inactivePciHostdevs, dev);
|
virPCIDeviceListDel(driver->inactivePciHostdevs, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loop 7: Now set the used_by_domain of the device in
|
/* Loop 7: Now set the used_by_domain of the device in
|
||||||
* driver->activePciHostdevs as domain name.
|
* driver->activePciHostdevs as domain name.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
|
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
|
||||||
pciDevice *dev, *activeDev;
|
virPCIDevicePtr dev, activeDev;
|
||||||
|
|
||||||
dev = pciDeviceListGet(pcidevs, i);
|
dev = virPCIDeviceListGet(pcidevs, i);
|
||||||
activeDev = pciDeviceListFind(driver->activePciHostdevs, dev);
|
activeDev = virPCIDeviceListFind(driver->activePciHostdevs, dev);
|
||||||
|
|
||||||
if (activeDev)
|
if (activeDev)
|
||||||
pciDeviceSetUsedBy(activeDev, name);
|
virPCIDeviceSetUsedBy(activeDev, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loop 8: Now set the original states for hostdev def */
|
/* Loop 8: Now set the original states for hostdev def */
|
||||||
for (i = 0; i < nhostdevs; i++) {
|
for (i = 0; i < nhostdevs; i++) {
|
||||||
pciDevice *dev;
|
virPCIDevicePtr dev;
|
||||||
pciDevice *pcidev;
|
virPCIDevicePtr pcidev;
|
||||||
virDomainHostdevDefPtr hostdev = hostdevs[i];
|
virDomainHostdevDefPtr hostdev = hostdevs[i];
|
||||||
|
|
||||||
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
||||||
@ -527,7 +527,7 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
|
|||||||
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dev = pciGetDevice(hostdev->source.subsys.u.pci.domain,
|
dev = virPCIDeviceNew(hostdev->source.subsys.u.pci.domain,
|
||||||
hostdev->source.subsys.u.pci.bus,
|
hostdev->source.subsys.u.pci.bus,
|
||||||
hostdev->source.subsys.u.pci.slot,
|
hostdev->source.subsys.u.pci.slot,
|
||||||
hostdev->source.subsys.u.pci.function);
|
hostdev->source.subsys.u.pci.function);
|
||||||
@ -536,32 +536,32 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
|
|||||||
* "reprobe" were already set by pciDettachDevice in
|
* "reprobe" were already set by pciDettachDevice in
|
||||||
* loop 2.
|
* loop 2.
|
||||||
*/
|
*/
|
||||||
if ((pcidev = pciDeviceListFind(pcidevs, dev))) {
|
if ((pcidev = virPCIDeviceListFind(pcidevs, dev))) {
|
||||||
hostdev->origstates.states.pci.unbind_from_stub =
|
hostdev->origstates.states.pci.unbind_from_stub =
|
||||||
pciDeviceGetUnbindFromStub(pcidev);
|
virPCIDeviceGetUnbindFromStub(pcidev);
|
||||||
hostdev->origstates.states.pci.remove_slot =
|
hostdev->origstates.states.pci.remove_slot =
|
||||||
pciDeviceGetRemoveSlot(pcidev);
|
virPCIDeviceGetRemoveSlot(pcidev);
|
||||||
hostdev->origstates.states.pci.reprobe =
|
hostdev->origstates.states.pci.reprobe =
|
||||||
pciDeviceGetReprobe(pcidev);
|
virPCIDeviceGetReprobe(pcidev);
|
||||||
}
|
}
|
||||||
|
|
||||||
pciFreeDevice(dev);
|
virPCIDeviceFree(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loop 9: Now steal all the devices from pcidevs */
|
/* Loop 9: Now steal all the devices from pcidevs */
|
||||||
while (pciDeviceListCount(pcidevs) > 0)
|
while (virPCIDeviceListCount(pcidevs) > 0)
|
||||||
pciDeviceListStealIndex(pcidevs, 0);
|
virPCIDeviceListStealIndex(pcidevs, 0);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
inactivedevs:
|
inactivedevs:
|
||||||
/* Only steal all the devices from driver->activePciHostdevs. We will
|
/* Only steal all the devices from driver->activePciHostdevs. We will
|
||||||
* free them in pciDeviceListFree().
|
* free them in virPCIDeviceListFree().
|
||||||
*/
|
*/
|
||||||
while (pciDeviceListCount(pcidevs) > 0) {
|
while (virPCIDeviceListCount(pcidevs) > 0) {
|
||||||
pciDevice *dev = pciDeviceListGet(pcidevs, 0);
|
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, 0);
|
||||||
pciDeviceListSteal(driver->activePciHostdevs, dev);
|
virPCIDeviceListSteal(driver->activePciHostdevs, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetvfnetconfig:
|
resetvfnetconfig:
|
||||||
@ -574,13 +574,13 @@ resetvfnetconfig:
|
|||||||
}
|
}
|
||||||
|
|
||||||
reattachdevs:
|
reattachdevs:
|
||||||
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
|
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
|
||||||
pciDevice *dev = pciDeviceListGet(pcidevs, i);
|
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
|
||||||
pciReAttachDevice(dev, driver->activePciHostdevs, NULL, "pci-stub");
|
virPCIDeviceReattach(dev, driver->activePciHostdevs, NULL, "pci-stub");
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
pciDeviceListFree(pcidevs);
|
virPCIDeviceListFree(pcidevs);
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
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;
|
int retries = 100;
|
||||||
|
|
||||||
/* If the device is not managed and was attached to guest
|
/* If the device is not managed and was attached to guest
|
||||||
* successfully, it must have been inactive.
|
* successfully, it must have been inactive.
|
||||||
*/
|
*/
|
||||||
if (!pciDeviceGetManaged(dev)) {
|
if (!virPCIDeviceGetManaged(dev)) {
|
||||||
if (pciDeviceListAdd(driver->inactivePciHostdevs, dev) < 0)
|
if (virPCIDeviceListAdd(driver->inactivePciHostdevs, dev) < 0)
|
||||||
pciFreeDevice(dev);
|
virPCIDeviceFree(dev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (pciWaitForDeviceCleanup(dev, "kvm_assigned_device")
|
while (virPCIDeviceWaitForCleanup(dev, "kvm_assigned_device")
|
||||||
&& retries) {
|
&& retries) {
|
||||||
usleep(100*1000);
|
usleep(100*1000);
|
||||||
retries--;
|
retries--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pciReAttachDevice(dev, driver->activePciHostdevs,
|
if (virPCIDeviceReattach(dev, driver->activePciHostdevs,
|
||||||
driver->inactivePciHostdevs, "pci-stub") < 0) {
|
driver->inactivePciHostdevs, "pci-stub") < 0) {
|
||||||
virErrorPtr err = virGetLastError();
|
virErrorPtr err = virGetLastError();
|
||||||
VIR_ERROR(_("Failed to re-attach PCI device: %s"),
|
VIR_ERROR(_("Failed to re-attach PCI device: %s"),
|
||||||
err ? err->message : _("unknown error"));
|
err ? err->message : _("unknown error"));
|
||||||
virResetError(err);
|
virResetError(err);
|
||||||
}
|
}
|
||||||
pciFreeDevice(dev);
|
virPCIDeviceFree(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -848,7 +848,7 @@ void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
|
|||||||
virDomainHostdevDefPtr *hostdevs,
|
virDomainHostdevDefPtr *hostdevs,
|
||||||
int nhostdevs)
|
int nhostdevs)
|
||||||
{
|
{
|
||||||
pciDeviceList *pcidevs;
|
virPCIDeviceListPtr pcidevs;
|
||||||
int i;
|
int i;
|
||||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
|
||||||
@ -856,7 +856,7 @@ void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
|
|||||||
hostdevs,
|
hostdevs,
|
||||||
nhostdevs))) {
|
nhostdevs))) {
|
||||||
virErrorPtr err = virGetLastError();
|
virErrorPtr err = virGetLastError();
|
||||||
VIR_ERROR(_("Failed to allocate pciDeviceList: %s"),
|
VIR_ERROR(_("Failed to allocate PCI device list: %s"),
|
||||||
err ? err->message : _("unknown error"));
|
err ? err->message : _("unknown error"));
|
||||||
virResetError(err);
|
virResetError(err);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -866,22 +866,22 @@ void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
|
|||||||
* them and reset all the devices before re-attach.
|
* them and reset all the devices before re-attach.
|
||||||
* Attach mac and port profile parameters to devices
|
* Attach mac and port profile parameters to devices
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
|
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
|
||||||
pciDevice *dev = pciDeviceListGet(pcidevs, i);
|
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
|
||||||
pciDevice *activeDev = NULL;
|
virPCIDevicePtr activeDev = NULL;
|
||||||
|
|
||||||
/* Never delete the dev from list driver->activePciHostdevs
|
/* Never delete the dev from list driver->activePciHostdevs
|
||||||
* if it's used by other domain.
|
* if it's used by other domain.
|
||||||
*/
|
*/
|
||||||
activeDev = pciDeviceListFind(driver->activePciHostdevs, dev);
|
activeDev = virPCIDeviceListFind(driver->activePciHostdevs, dev);
|
||||||
if (activeDev &&
|
if (activeDev &&
|
||||||
STRNEQ_NULLABLE(name, pciDeviceGetUsedBy(activeDev))) {
|
STRNEQ_NULLABLE(name, virPCIDeviceGetUsedBy(activeDev))) {
|
||||||
pciDeviceListSteal(pcidevs, dev);
|
virPCIDeviceListSteal(pcidevs, dev);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pciDeviceListFree() will take care of freeing the dev. */
|
/* virPCIDeviceListFree() will take care of freeing the dev. */
|
||||||
pciDeviceListSteal(driver->activePciHostdevs, dev);
|
virPCIDeviceListSteal(driver->activePciHostdevs, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -900,9 +900,9 @@ void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
|
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
|
||||||
pciDevice *dev = pciDeviceListGet(pcidevs, i);
|
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
|
||||||
if (pciResetDevice(dev, driver->activePciHostdevs,
|
if (virPCIDeviceReset(dev, driver->activePciHostdevs,
|
||||||
driver->inactivePciHostdevs) < 0) {
|
driver->inactivePciHostdevs) < 0) {
|
||||||
virErrorPtr err = virGetLastError();
|
virErrorPtr err = virGetLastError();
|
||||||
VIR_ERROR(_("Failed to reset PCI device: %s"),
|
VIR_ERROR(_("Failed to reset PCI device: %s"),
|
||||||
@ -911,12 +911,12 @@ void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (pciDeviceListCount(pcidevs) > 0) {
|
while (virPCIDeviceListCount(pcidevs) > 0) {
|
||||||
pciDevice *dev = pciDeviceListStealIndex(pcidevs, 0);
|
virPCIDevicePtr dev = virPCIDeviceListStealIndex(pcidevs, 0);
|
||||||
qemuReattachPciDevice(dev, driver);
|
qemuReattachPciDevice(dev, driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
pciDeviceListFree(pcidevs);
|
virPCIDeviceListFree(pcidevs);
|
||||||
cleanup:
|
cleanup:
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ int qemuPrepareHostdevUSBDevices(virQEMUDriverPtr driver,
|
|||||||
int qemuPrepareHostDevices(virQEMUDriverPtr driver,
|
int qemuPrepareHostDevices(virQEMUDriverPtr driver,
|
||||||
virDomainDefPtr def,
|
virDomainDefPtr def,
|
||||||
bool coldBoot);
|
bool coldBoot);
|
||||||
void qemuReattachPciDevice(pciDevice *dev, virQEMUDriverPtr driver);
|
void qemuReattachPciDevice(virPCIDevicePtr dev, virQEMUDriverPtr driver);
|
||||||
void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
|
void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
|
||||||
const char *name,
|
const char *name,
|
||||||
virDomainHostdevDefPtr *hostdevs,
|
virDomainHostdevDefPtr *hostdevs,
|
||||||
|
@ -2331,8 +2331,8 @@ qemuDomainDetachHostPciDevice(virQEMUDriverPtr driver,
|
|||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virDomainHostdevSubsysPtr subsys = &detach->source.subsys;
|
virDomainHostdevSubsysPtr subsys = &detach->source.subsys;
|
||||||
int ret = -1, rv;
|
int ret = -1, rv;
|
||||||
pciDevice *pci;
|
virPCIDevicePtr pci;
|
||||||
pciDevice *activePci;
|
virPCIDevicePtr activePci;
|
||||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
|
||||||
if (qemuIsMultiFunctionDevice(vm->def, detach->info)) {
|
if (qemuIsMultiFunctionDevice(vm->def, detach->info)) {
|
||||||
@ -2368,20 +2368,20 @@ qemuDomainDetachHostPciDevice(virQEMUDriverPtr driver,
|
|||||||
if (detach->parent.data.net)
|
if (detach->parent.data.net)
|
||||||
qemuDomainHostdevNetConfigRestore(detach, cfg->stateDir);
|
qemuDomainHostdevNetConfigRestore(detach, cfg->stateDir);
|
||||||
|
|
||||||
pci = pciGetDevice(subsys->u.pci.domain, subsys->u.pci.bus,
|
pci = virPCIDeviceNew(subsys->u.pci.domain, subsys->u.pci.bus,
|
||||||
subsys->u.pci.slot, subsys->u.pci.function);
|
subsys->u.pci.slot, subsys->u.pci.function);
|
||||||
if (pci) {
|
if (pci) {
|
||||||
activePci = pciDeviceListSteal(driver->activePciHostdevs, pci);
|
activePci = virPCIDeviceListSteal(driver->activePciHostdevs, pci);
|
||||||
if (activePci &&
|
if (activePci &&
|
||||||
pciResetDevice(activePci, driver->activePciHostdevs,
|
virPCIDeviceReset(activePci, driver->activePciHostdevs,
|
||||||
driver->inactivePciHostdevs) == 0) {
|
driver->inactivePciHostdevs) == 0) {
|
||||||
qemuReattachPciDevice(activePci, driver);
|
qemuReattachPciDevice(activePci, driver);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
/* reset of the device failed, treat it as if it was returned */
|
/* 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) &&
|
if (qemuCapsGet(priv->caps, QEMU_CAPS_DEVICE) &&
|
||||||
|
@ -328,7 +328,7 @@ AppArmorSetSecurityUSBLabel(usbDevice *dev ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
AppArmorSetSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
|
AppArmorSetSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
|
||||||
const char *file, void *opaque)
|
const char *file, void *opaque)
|
||||||
{
|
{
|
||||||
struct SDPDOP *ptr = opaque;
|
struct SDPDOP *ptr = opaque;
|
||||||
@ -783,7 +783,8 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
||||||
pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain,
|
virPCIDevicePtr pci =
|
||||||
|
virPCIDeviceNew(dev->source.subsys.u.pci.domain,
|
||||||
dev->source.subsys.u.pci.bus,
|
dev->source.subsys.u.pci.bus,
|
||||||
dev->source.subsys.u.pci.slot,
|
dev->source.subsys.u.pci.slot,
|
||||||
dev->source.subsys.u.pci.function);
|
dev->source.subsys.u.pci.function);
|
||||||
@ -791,8 +792,8 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
|
|||||||
if (!pci)
|
if (!pci)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
ret = pciDeviceFileIterate(pci, AppArmorSetSecurityPCILabel, ptr);
|
ret = virPCIDeviceFileIterate(pci, AppArmorSetSecurityPCILabel, ptr);
|
||||||
pciFreeDevice(pci);
|
virPCIDeviceFree(pci);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ virSecurityDACRestoreSecurityImageLabel(virSecurityManagerPtr mgr,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virSecurityDACSetSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
|
virSecurityDACSetSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
|
||||||
const char *file,
|
const char *file,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
@ -507,7 +507,8 @@ virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
||||||
pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain,
|
virPCIDevicePtr pci =
|
||||||
|
virPCIDeviceNew(dev->source.subsys.u.pci.domain,
|
||||||
dev->source.subsys.u.pci.bus,
|
dev->source.subsys.u.pci.bus,
|
||||||
dev->source.subsys.u.pci.slot,
|
dev->source.subsys.u.pci.slot,
|
||||||
dev->source.subsys.u.pci.function);
|
dev->source.subsys.u.pci.function);
|
||||||
@ -515,9 +516,9 @@ virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
|
|||||||
if (!pci)
|
if (!pci)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
ret = pciDeviceFileIterate(pci, virSecurityDACSetSecurityPCILabel,
|
ret = virPCIDeviceFileIterate(pci, virSecurityDACSetSecurityPCILabel,
|
||||||
params);
|
params);
|
||||||
pciFreeDevice(pci);
|
virPCIDeviceFree(pci);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -533,7 +534,7 @@ done:
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virSecurityDACRestoreSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
|
virSecurityDACRestoreSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
|
||||||
const char *file,
|
const char *file,
|
||||||
void *opaque ATTRIBUTE_UNUSED)
|
void *opaque ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
@ -586,7 +587,8 @@ virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
||||||
pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain,
|
virPCIDevicePtr pci =
|
||||||
|
virPCIDeviceNew(dev->source.subsys.u.pci.domain,
|
||||||
dev->source.subsys.u.pci.bus,
|
dev->source.subsys.u.pci.bus,
|
||||||
dev->source.subsys.u.pci.slot,
|
dev->source.subsys.u.pci.slot,
|
||||||
dev->source.subsys.u.pci.function);
|
dev->source.subsys.u.pci.function);
|
||||||
@ -594,8 +596,8 @@ virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr,
|
|||||||
if (!pci)
|
if (!pci)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
ret = pciDeviceFileIterate(pci, virSecurityDACRestoreSecurityPCILabel, mgr);
|
ret = virPCIDeviceFileIterate(pci, virSecurityDACRestoreSecurityPCILabel, mgr);
|
||||||
pciFreeDevice(pci);
|
virPCIDeviceFree(pci);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1159,7 +1159,7 @@ virSecuritySELinuxSetSecurityImageLabel(virSecurityManagerPtr mgr,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virSecuritySELinuxSetSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
|
virSecuritySELinuxSetSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
|
||||||
const char *file, void *opaque)
|
const char *file, void *opaque)
|
||||||
{
|
{
|
||||||
virSecurityLabelDefPtr secdef;
|
virSecurityLabelDefPtr secdef;
|
||||||
@ -1213,7 +1213,8 @@ virSecuritySELinuxSetSecurityHostdevSubsysLabel(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
||||||
pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain,
|
virPCIDevicePtr pci =
|
||||||
|
virPCIDeviceNew(dev->source.subsys.u.pci.domain,
|
||||||
dev->source.subsys.u.pci.bus,
|
dev->source.subsys.u.pci.bus,
|
||||||
dev->source.subsys.u.pci.slot,
|
dev->source.subsys.u.pci.slot,
|
||||||
dev->source.subsys.u.pci.function);
|
dev->source.subsys.u.pci.function);
|
||||||
@ -1221,8 +1222,8 @@ virSecuritySELinuxSetSecurityHostdevSubsysLabel(virDomainDefPtr def,
|
|||||||
if (!pci)
|
if (!pci)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
ret = pciDeviceFileIterate(pci, virSecuritySELinuxSetSecurityPCILabel, def);
|
ret = virPCIDeviceFileIterate(pci, virSecuritySELinuxSetSecurityPCILabel, def);
|
||||||
pciFreeDevice(pci);
|
virPCIDeviceFree(pci);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1326,7 +1327,7 @@ virSecuritySELinuxSetSecurityHostdevLabel(virSecurityManagerPtr mgr ATTRIBUTE_UN
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virSecuritySELinuxRestoreSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
|
virSecuritySELinuxRestoreSecurityPCILabel(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
|
||||||
const char *file,
|
const char *file,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
@ -1374,7 +1375,8 @@ virSecuritySELinuxRestoreSecurityHostdevSubsysLabel(virSecurityManagerPtr mgr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
||||||
pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain,
|
virPCIDevicePtr pci =
|
||||||
|
virPCIDeviceNew(dev->source.subsys.u.pci.domain,
|
||||||
dev->source.subsys.u.pci.bus,
|
dev->source.subsys.u.pci.bus,
|
||||||
dev->source.subsys.u.pci.slot,
|
dev->source.subsys.u.pci.slot,
|
||||||
dev->source.subsys.u.pci.function);
|
dev->source.subsys.u.pci.function);
|
||||||
@ -1382,8 +1384,8 @@ virSecuritySELinuxRestoreSecurityHostdevSubsysLabel(virSecurityManagerPtr mgr,
|
|||||||
if (!pci)
|
if (!pci)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
ret = pciDeviceFileIterate(pci, virSecuritySELinuxRestoreSecurityPCILabel, mgr);
|
ret = virPCIDeviceFileIterate(pci, virSecuritySELinuxRestoreSecurityPCILabel, mgr);
|
||||||
pciFreeDevice(pci);
|
virPCIDeviceFree(pci);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -853,7 +853,7 @@ file_iterate_hostdev_cb(usbDevice *dev ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
file_iterate_pci_cb(pciDevice *dev ATTRIBUTE_UNUSED,
|
file_iterate_pci_cb(virPCIDevicePtr dev ATTRIBUTE_UNUSED,
|
||||||
const char *file, void *opaque)
|
const char *file, void *opaque)
|
||||||
{
|
{
|
||||||
virBufferPtr buf = opaque;
|
virBufferPtr buf = opaque;
|
||||||
@ -1022,7 +1022,7 @@ get_files(vahControl * ctl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
|
||||||
pciDevice *pci = pciGetDevice(
|
virPCIDevicePtr pci = virPCIDeviceNew(
|
||||||
dev->source.subsys.u.pci.domain,
|
dev->source.subsys.u.pci.domain,
|
||||||
dev->source.subsys.u.pci.bus,
|
dev->source.subsys.u.pci.bus,
|
||||||
dev->source.subsys.u.pci.slot,
|
dev->source.subsys.u.pci.slot,
|
||||||
@ -1031,8 +1031,8 @@ get_files(vahControl * ctl)
|
|||||||
if (pci == NULL)
|
if (pci == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rc = pciDeviceFileIterate(pci, file_iterate_pci_cb, &buf);
|
rc = virPCIDeviceFileIterate(pci, file_iterate_pci_cb, &buf);
|
||||||
pciFreeDevice(pci);
|
virPCIDeviceFree(pci);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -980,7 +980,7 @@ virNetDevSysfsDeviceFile(char **pf_sysfs_device_link, const char *ifname,
|
|||||||
int
|
int
|
||||||
virNetDevGetVirtualFunctions(const char *pfname,
|
virNetDevGetVirtualFunctions(const char *pfname,
|
||||||
char ***vfname,
|
char ***vfname,
|
||||||
struct pci_config_address ***virt_fns,
|
virPCIDeviceAddressPtr **virt_fns,
|
||||||
unsigned int *n_vfname)
|
unsigned int *n_vfname)
|
||||||
{
|
{
|
||||||
int ret = -1, i;
|
int ret = -1, i;
|
||||||
@ -991,7 +991,7 @@ virNetDevGetVirtualFunctions(const char *pfname,
|
|||||||
if (virNetDevSysfsFile(&pf_sysfs_device_link, pfname, "device") < 0)
|
if (virNetDevSysfsFile(&pf_sysfs_device_link, pfname, "device") < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (pciGetVirtualFunctions(pf_sysfs_device_link, virt_fns,
|
if (virPCIGetVirtualFunctions(pf_sysfs_device_link, virt_fns,
|
||||||
n_vfname) < 0)
|
n_vfname) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -1002,7 +1002,7 @@ virNetDevGetVirtualFunctions(const char *pfname,
|
|||||||
|
|
||||||
for (i = 0; i < *n_vfname; i++)
|
for (i = 0; i < *n_vfname; i++)
|
||||||
{
|
{
|
||||||
if (pciGetDeviceAddrString((*virt_fns)[i]->domain,
|
if (virPCIGetAddrString((*virt_fns)[i]->domain,
|
||||||
(*virt_fns)[i]->bus,
|
(*virt_fns)[i]->bus,
|
||||||
(*virt_fns)[i]->slot,
|
(*virt_fns)[i]->slot,
|
||||||
(*virt_fns)[i]->function,
|
(*virt_fns)[i]->function,
|
||||||
@ -1011,13 +1011,13 @@ virNetDevGetVirtualFunctions(const char *pfname,
|
|||||||
_("Failed to get PCI Config Address String"));
|
_("Failed to get PCI Config Address String"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (pciSysfsFile(pciConfigAddr, &pci_sysfs_device_link) < 0) {
|
if (virPCIGetSysfsFile(pciConfigAddr, &pci_sysfs_device_link) < 0) {
|
||||||
virReportSystemError(ENOSYS, "%s",
|
virReportSystemError(ENOSYS, "%s",
|
||||||
_("Failed to get PCI SYSFS file"));
|
_("Failed to get PCI SYSFS file"));
|
||||||
goto cleanup;
|
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");
|
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)
|
if (virNetDevSysfsFile(&if_sysfs_device_link, ifname, "device") < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = pciDeviceIsVirtualFunction(if_sysfs_device_link);
|
ret = virPCIIsVirtualFunction(if_sysfs_device_link);
|
||||||
|
|
||||||
VIR_FREE(if_sysfs_device_link);
|
VIR_FREE(if_sysfs_device_link);
|
||||||
|
|
||||||
@ -1086,7 +1086,7 @@ virNetDevGetVirtualFunctionIndex(const char *pfname, const char *vfname,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pciGetVirtualFunctionIndex(pf_sysfs_device_link,
|
ret = virPCIGetVirtualFunctionIndex(pf_sysfs_device_link,
|
||||||
vf_sysfs_device_link,
|
vf_sysfs_device_link,
|
||||||
vf_index);
|
vf_index);
|
||||||
|
|
||||||
@ -1115,7 +1115,7 @@ virNetDevGetPhysicalFunction(const char *ifname, char **pfname)
|
|||||||
if (virNetDevSysfsDeviceFile(&physfn_sysfs_path, ifname, "physfn") < 0)
|
if (virNetDevSysfsDeviceFile(&physfn_sysfs_path, ifname, "physfn") < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = pciDeviceNetName(physfn_sysfs_path, pfname);
|
ret = virPCIGetNetName(physfn_sysfs_path, pfname);
|
||||||
|
|
||||||
VIR_FREE(physfn_sysfs_path);
|
VIR_FREE(physfn_sysfs_path);
|
||||||
|
|
||||||
@ -1149,7 +1149,7 @@ virNetDevGetVirtualFunctionInfo(const char *vfname, char **pfname,
|
|||||||
if (virNetDevSysfsFile(&vf_sysfs_path, vfname, "device") < 0)
|
if (virNetDevSysfsFile(&vf_sysfs_path, vfname, "device") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = pciGetVirtualFunctionIndex(pf_sysfs_path, vf_sysfs_path, vf);
|
ret = virPCIGetVirtualFunctionIndex(pf_sysfs_path, vf_sysfs_path, vf);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -1165,7 +1165,7 @@ cleanup:
|
|||||||
int
|
int
|
||||||
virNetDevGetVirtualFunctions(const char *pfname ATTRIBUTE_UNUSED,
|
virNetDevGetVirtualFunctions(const char *pfname ATTRIBUTE_UNUSED,
|
||||||
char ***vfname 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)
|
unsigned int *n_vfname ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
virReportSystemError(ENOSYS, "%s",
|
virReportSystemError(ENOSYS, "%s",
|
||||||
|
@ -104,7 +104,7 @@ int virNetDevGetPhysicalFunction(const char *ifname, char **pfname)
|
|||||||
|
|
||||||
int virNetDevGetVirtualFunctions(const char *pfname,
|
int virNetDevGetVirtualFunctions(const char *pfname,
|
||||||
char ***vfname,
|
char ***vfname,
|
||||||
struct pci_config_address ***virt_fns,
|
virPCIDeviceAddressPtr **virt_fns,
|
||||||
unsigned int *n_vfname)
|
unsigned int *n_vfname)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
||||||
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -26,67 +26,74 @@
|
|||||||
|
|
||||||
# include "internal.h"
|
# include "internal.h"
|
||||||
|
|
||||||
typedef struct _pciDevice pciDevice;
|
typedef struct _virPCIDevice virPCIDevice;
|
||||||
typedef struct _pciDeviceList pciDeviceList;
|
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 domain;
|
||||||
unsigned int bus;
|
unsigned int bus;
|
||||||
unsigned int slot;
|
unsigned int slot;
|
||||||
unsigned int function;
|
unsigned int function;
|
||||||
};
|
};
|
||||||
|
|
||||||
pciDevice *pciGetDevice (unsigned domain,
|
virPCIDevicePtr virPCIDeviceNew(unsigned domain,
|
||||||
unsigned bus,
|
unsigned bus,
|
||||||
unsigned slot,
|
unsigned slot,
|
||||||
unsigned function);
|
unsigned function);
|
||||||
void pciFreeDevice (pciDevice *dev);
|
void virPCIDeviceFree(virPCIDevicePtr dev);
|
||||||
const char *pciDeviceGetName (pciDevice *dev);
|
const char *virPCIDeviceGetName(virPCIDevicePtr 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);
|
|
||||||
|
|
||||||
pciDeviceList *pciDeviceListNew (void);
|
int virPCIDeviceDetach(virPCIDevicePtr dev,
|
||||||
void pciDeviceListFree (pciDeviceList *list);
|
virPCIDeviceListPtr activeDevs,
|
||||||
int pciDeviceListAdd (pciDeviceList *list,
|
virPCIDeviceListPtr inactiveDevs,
|
||||||
pciDevice *dev);
|
const char *driver);
|
||||||
pciDevice * pciDeviceListGet (pciDeviceList *list,
|
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 idx);
|
||||||
int pciDeviceListCount (pciDeviceList *list);
|
int virPCIDeviceListCount(virPCIDeviceListPtr list);
|
||||||
pciDevice * pciDeviceListSteal (pciDeviceList *list,
|
virPCIDevicePtr virPCIDeviceListSteal(virPCIDeviceListPtr list,
|
||||||
pciDevice *dev);
|
virPCIDevicePtr dev);
|
||||||
pciDevice * pciDeviceListStealIndex(pciDeviceList *list,
|
virPCIDevicePtr virPCIDeviceListStealIndex(virPCIDeviceListPtr list,
|
||||||
int idx);
|
int idx);
|
||||||
void pciDeviceListDel (pciDeviceList *list,
|
void virPCIDeviceListDel(virPCIDeviceListPtr list,
|
||||||
pciDevice *dev);
|
virPCIDevicePtr dev);
|
||||||
pciDevice * pciDeviceListFind (pciDeviceList *list,
|
virPCIDevicePtr virPCIDeviceListFind(virPCIDeviceListPtr list,
|
||||||
pciDevice *dev);
|
virPCIDevicePtr dev);
|
||||||
int pciDeviceListFindIndex(pciDeviceList *list,
|
int virPCIDeviceListFindIndex(virPCIDeviceListPtr list,
|
||||||
pciDevice *dev);
|
virPCIDevicePtr dev);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Callback that will be invoked once for each file
|
* Callback that will be invoked once for each file
|
||||||
@ -95,46 +102,47 @@ int pciDeviceListFindIndex(pciDeviceList *list,
|
|||||||
* Should return 0 if successfully processed, or
|
* Should return 0 if successfully processed, or
|
||||||
* -1 to indicate error and abort iteration
|
* -1 to indicate error and abort iteration
|
||||||
*/
|
*/
|
||||||
typedef int (*pciDeviceFileActor)(pciDevice *dev,
|
typedef int (*virPCIDeviceFileActor)(virPCIDevicePtr dev,
|
||||||
const char *path, void *opaque);
|
const char *path, void *opaque);
|
||||||
|
|
||||||
int pciDeviceFileIterate(pciDevice *dev,
|
int virPCIDeviceFileIterate(virPCIDevicePtr dev,
|
||||||
pciDeviceFileActor actor,
|
virPCIDeviceFileActor actor,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
|
||||||
int pciDeviceIsAssignable(pciDevice *dev,
|
int virPCIDeviceIsAssignable(virPCIDevicePtr dev,
|
||||||
int strict_acs_check);
|
int strict_acs_check);
|
||||||
int pciWaitForDeviceCleanup(pciDevice *dev, const char *matcher);
|
int virPCIDeviceWaitForCleanup(virPCIDevicePtr dev, const char *matcher);
|
||||||
|
|
||||||
int pciGetPhysicalFunction(const char *sysfs_path,
|
int virPCIGetPhysicalFunction(const char *sysfs_path,
|
||||||
struct pci_config_address **phys_fn);
|
virPCIDeviceAddressPtr *phys_fn);
|
||||||
|
|
||||||
int pciGetVirtualFunctions(const char *sysfs_path,
|
int virPCIGetVirtualFunctions(const char *sysfs_path,
|
||||||
struct pci_config_address ***virtual_functions,
|
virPCIDeviceAddressPtr **virtual_functions,
|
||||||
unsigned int *num_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,
|
int virPCIGetVirtualFunctionIndex(const char *pf_sysfs_device_link,
|
||||||
const char *vf_sysfs_device_link,
|
const char *vf_sysfs_device_link,
|
||||||
int *vf_index);
|
int *vf_index);
|
||||||
|
|
||||||
int pciConfigAddressToSysfsFile(struct pci_config_address *dev,
|
int virPCIDeviceAddressGetSysfsFile(virPCIDeviceAddressPtr dev,
|
||||||
char **pci_sysfs_device_link);
|
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;
|
ATTRIBUTE_RETURN_CHECK;
|
||||||
|
|
||||||
int pciGetDeviceAddrString(unsigned domain,
|
int virPCIGetAddrString(unsigned domain,
|
||||||
unsigned bus,
|
unsigned bus,
|
||||||
unsigned slot,
|
unsigned slot,
|
||||||
unsigned function,
|
unsigned function,
|
||||||
char **pciConfigAddr)
|
char **pciConfigAddr)
|
||||||
ATTRIBUTE_NONNULL(5) ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_NONNULL(5) ATTRIBUTE_RETURN_CHECK;
|
||||||
|
|
||||||
int pciDeviceGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
|
int virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
|
||||||
char **pfname, int *vf_index);
|
char **pfname, int *vf_index);
|
||||||
|
|
||||||
#endif /* __VIR_PCI_H__ */
|
#endif /* __VIR_PCI_H__ */
|
||||||
|
@ -2102,23 +2102,23 @@ out:
|
|||||||
static int
|
static int
|
||||||
xenUnifiedNodeDeviceDettach(virNodeDevicePtr dev)
|
xenUnifiedNodeDeviceDettach(virNodeDevicePtr dev)
|
||||||
{
|
{
|
||||||
pciDevice *pci;
|
virPCIDevicePtr pci;
|
||||||
unsigned domain, bus, slot, function;
|
unsigned domain, bus, slot, function;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pci = pciGetDevice(domain, bus, slot, function);
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
||||||
if (!pci)
|
if (!pci)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (pciDettachDevice(pci, NULL, NULL, "pciback") < 0)
|
if (virPCIDeviceDetach(pci, NULL, NULL, "pciback") < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
out:
|
out:
|
||||||
pciFreeDevice(pci);
|
virPCIDeviceFree(pci);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2183,7 +2183,7 @@ out:
|
|||||||
static int
|
static int
|
||||||
xenUnifiedNodeDeviceReAttach(virNodeDevicePtr dev)
|
xenUnifiedNodeDeviceReAttach(virNodeDevicePtr dev)
|
||||||
{
|
{
|
||||||
pciDevice *pci;
|
virPCIDevicePtr pci;
|
||||||
unsigned domain, bus, slot, function;
|
unsigned domain, bus, slot, function;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int domid;
|
int domid;
|
||||||
@ -2191,7 +2191,7 @@ xenUnifiedNodeDeviceReAttach(virNodeDevicePtr dev)
|
|||||||
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pci = pciGetDevice(domain, bus, slot, function);
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
||||||
if (!pci)
|
if (!pci)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -2203,35 +2203,35 @@ xenUnifiedNodeDeviceReAttach(virNodeDevicePtr dev)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pciReAttachDevice(pci, NULL, NULL, "pciback") < 0)
|
if (virPCIDeviceReattach(pci, NULL, NULL, "pciback") < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
out:
|
out:
|
||||||
pciFreeDevice(pci);
|
virPCIDeviceFree(pci);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xenUnifiedNodeDeviceReset(virNodeDevicePtr dev)
|
xenUnifiedNodeDeviceReset(virNodeDevicePtr dev)
|
||||||
{
|
{
|
||||||
pciDevice *pci;
|
virPCIDevicePtr pci;
|
||||||
unsigned domain, bus, slot, function;
|
unsigned domain, bus, slot, function;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pci = pciGetDevice(domain, bus, slot, function);
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
||||||
if (!pci)
|
if (!pci)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (pciResetDevice(pci, NULL, NULL) < 0)
|
if (virPCIDeviceReset(pci, NULL, NULL) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
out:
|
out:
|
||||||
pciFreeDevice(pci);
|
virPCIDeviceFree(pci);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user