mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
hostdev: Use actual device when reattaching
Instead of forcing the values for the unbind_from_stub, remove_slot and reprobe properties, look up the actual device and use that when calling virPCIDeviceReattach(). This ensures the device is restored to its original state after reattach: for example, if it was not bound to any driver before detach, it will not be bound forcefully during reattach.
This commit is contained in:
parent
c3e2f6e37d
commit
ee4cfb5643
@ -1658,6 +1658,7 @@ virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr mgr,
|
|||||||
virPCIDevicePtr pci)
|
virPCIDevicePtr pci)
|
||||||
{
|
{
|
||||||
struct virHostdevIsPCINodeDeviceUsedData data = { mgr, NULL, false };
|
struct virHostdevIsPCINodeDeviceUsedData data = { mgr, NULL, false };
|
||||||
|
virPCIDevicePtr actual;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
virObjectLock(mgr->activePCIHostdevs);
|
virObjectLock(mgr->activePCIHostdevs);
|
||||||
@ -1666,11 +1667,12 @@ virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr mgr,
|
|||||||
if (virHostdevIsPCINodeDeviceUsed(virPCIDeviceGetAddress(pci), &data))
|
if (virHostdevIsPCINodeDeviceUsed(virPCIDeviceGetAddress(pci), &data))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virPCIDeviceSetUnbindFromStub(pci, true);
|
/* We need to look up the actual device because that's what
|
||||||
virPCIDeviceSetRemoveSlot(pci, true);
|
* virPCIDeviceReattach() expects as its argument */
|
||||||
virPCIDeviceSetReprobe(pci, true);
|
if (!(actual = virPCIDeviceListFind(mgr->inactivePCIHostdevs, pci)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (virPCIDeviceReattach(pci, mgr->activePCIHostdevs,
|
if (virPCIDeviceReattach(actual, mgr->activePCIHostdevs,
|
||||||
mgr->inactivePCIHostdevs) < 0)
|
mgr->inactivePCIHostdevs) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user