* reset them */
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
- if (pciResetDevice(dev, driver->activePciHostdevs) < 0)
+ if (pciResetDevice(dev, driver->activePciHostdevs, pcidevs) < 0)
goto cleanup;
}
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
- if (pciResetDevice(dev, driver->activePciHostdevs) < 0) {
+ if (pciResetDevice(dev, driver->activePciHostdevs, pcidevs) < 0) {
virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to reset PCI device: %s"),
err ? err->message : _("unknown error"));
else {
pciDeviceSetManaged(pci, detach->managed);
pciDeviceListDel(driver->activePciHostdevs, pci);
- if (pciResetDevice(pci, driver->activePciHostdevs) < 0)
+ if (pciResetDevice(pci, driver->activePciHostdevs, NULL) < 0)
ret = -1;
qemudReattachManagedDevice(pci, driver);
pciFreeDevice(pci);
qemuDriverLock(driver);
- if (pciResetDevice(pci, driver->activePciHostdevs) < 0)
+ if (pciResetDevice(pci, driver->activePciHostdevs, NULL) < 0)
goto out;
ret = 0;
return 0;
}
-/* Any active devices other than the one supplied on the same domain/bus ? */
+/* Any active devices on the same domain/bus ? */
static int
pciSharesBusWithActive(pciDevice *dev, pciDevice *check, void *data)
{
- pciDeviceList *activeDevs = data;
+ pciDeviceList *inactiveDevs = data;
/* Different domain, different bus, or simply identical device */
if (dev->domain != check->domain ||
dev->function == check->function))
return 0;
- if (activeDevs && !pciDeviceListFind(activeDevs, check))
+ /* same bus, but inactive, i.e. about to be assigned to guest */
+ if (inactiveDevs && pciDeviceListFind(inactiveDevs, check))
return 0;
return 1;
static pciDevice *
pciBusContainsActiveDevices(pciDevice *dev,
- pciDeviceList *activeDevs)
+ pciDeviceList *inactiveDevs)
{
pciDevice *active = NULL;
if (pciIterDevices(pciSharesBusWithActive,
- dev, &active, activeDevs) < 0)
+ dev, &active, inactiveDevs) < 0)
return NULL;
return active;
}
*/
static int
pciTrySecondaryBusReset(pciDevice *dev,
- pciDeviceList *activeDevs)
+ pciDeviceList *inactiveDevs)
{
pciDevice *parent, *conflict;
uint8_t config_space[PCI_CONF_LEN];
* In future, we could allow it so long as those devices
* are not in use by the host or other guests.
*/
- if ((conflict = pciBusContainsActiveDevices(dev, activeDevs))) {
+ if ((conflict = pciBusContainsActiveDevices(dev, inactiveDevs))) {
pciReportError(VIR_ERR_NO_SUPPORT,
_("Active %s devices on bus with %s, not doing bus reset"),
conflict->name, dev->name);
int
pciResetDevice(pciDevice *dev,
- pciDeviceList *activeDevs)
+ pciDeviceList *activeDevs,
+ pciDeviceList *inactiveDevs)
{
int ret = -1;
/* Bus reset is not an option with the root bus */
if (ret < 0 && dev->bus != 0)
- ret = pciTrySecondaryBusReset(dev, activeDevs);
+ ret = pciTrySecondaryBusReset(dev, inactiveDevs);
if (ret < 0) {
virErrorPtr err = virGetLastError();
int pciDettachDevice (pciDevice *dev, pciDeviceList *activeDevs);
int pciReAttachDevice (pciDevice *dev, pciDeviceList *activeDevs);
int pciResetDevice (pciDevice *dev,
- pciDeviceList *activeDevs);
+ pciDeviceList *activeDevs,
+ pciDeviceList *inactiveDevs);
void pciDeviceSetManaged(pciDevice *dev,
unsigned managed);
unsigned pciDeviceGetManaged(pciDevice *dev);