提交 a4efb2e3 编写于 作者: W Wen Congyang

reattach pci devices when qemuPrepareHostdevPCIDevices() failed

Reattach all pci devices that we detached when qemuPrepareHostdevPCIDevices()
failed.
上级 4e8969eb
...@@ -127,11 +127,11 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver, ...@@ -127,11 +127,11 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
for (i = 0; i < pciDeviceListCount(pcidevs); i++) { for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i); pciDevice *dev = pciDeviceListGet(pcidevs, i);
if (!pciDeviceIsAssignable(dev, !driver->relaxedACS)) if (!pciDeviceIsAssignable(dev, !driver->relaxedACS))
goto cleanup; goto reattachdevs;
if (pciDeviceGetManaged(dev) && if (pciDeviceGetManaged(dev) &&
pciDettachDevice(dev, driver->activePciHostdevs) < 0) pciDettachDevice(dev, driver->activePciHostdevs) < 0)
goto cleanup; goto reattachdevs;
} }
/* Now that all the PCI hostdevs have be dettached, we can safely /* Now that all the PCI hostdevs have be dettached, we can safely
...@@ -139,7 +139,7 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver, ...@@ -139,7 +139,7 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
for (i = 0; i < pciDeviceListCount(pcidevs); i++) { for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i); pciDevice *dev = pciDeviceListGet(pcidevs, i);
if (pciResetDevice(dev, driver->activePciHostdevs, pcidevs) < 0) if (pciResetDevice(dev, driver->activePciHostdevs, pcidevs) < 0)
goto cleanup; goto reattachdevs;
} }
/* Now mark all the devices as active */ /* Now mark all the devices as active */
...@@ -169,6 +169,12 @@ inactivedevs: ...@@ -169,6 +169,12 @@ inactivedevs:
pciDeviceListSteal(driver->activePciHostdevs, dev); pciDeviceListSteal(driver->activePciHostdevs, dev);
} }
reattachdevs:
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
pciReAttachDevice(dev, driver->activePciHostdevs);
}
cleanup: cleanup:
pciDeviceListFree(pcidevs); pciDeviceListFree(pcidevs);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册