[...]
>> - /* Step 5: Now mark all the devices as active */
>> + /* Step 5: Move devices from the inactive list to the active list */
>> for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
>> virPCIDevicePtr pci = virPCIDeviceListGet(pcidevs, i);
>> + virPCIDevicePtr actual;
>>
>> - VIR_DEBUG("Adding PCI device %s to active list",
>> + VIR_DEBUG("Removing PCI device %s from inactive list",
>> virPCIDeviceGetName(pci));
>> - if (virPCIDeviceListAdd(mgr->activePCIHostdevs, pci) < 0)
>> - goto inactivedevs;
>> - }
>> -
>> - /* Step 6: Now remove the devices from inactive list. */
>> - for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
>> - virPCIDevicePtr pci = virPCIDeviceListGet(pcidevs, i);
>> + actual = virPCIDeviceListSteal(mgr->inactivePCIHostdevs, pci);
>>
>> - VIR_DEBUG("Removing PCI device %s from inactive list",
>> + VIR_DEBUG("Adding PCI device %s to active list",
>> virPCIDeviceGetName(pci));
>> - virPCIDeviceListDel(mgr->inactivePCIHostdevs, pci);
>> + if (!actual || virPCIDeviceListAdd(mgr->activePCIHostdevs, actual)
< 0)
>> + goto inactivedevs;
>> }
>
> This is so much more logical to me than the previous code.
Yay :)
While writing the tomb for patch 20, I had one question/issue... You
could have already addressed in your upcoming patches, but I'll ask
anyway before I see them....
Essentially combining step5/step6 will *steal* from the inactiveList
(the rich) and give to the activeList (the poor). That's not a problem.
But, doesn't this mean only managed devices are moved to activeList as
opposed to all possible hostdevs (in pcidevs) - at least during Prepare?
Again it's this whole how does the inactiveList get populated conundrum
(vis-a-vis devices in the guest XML that are not managed).
Assuming the Reattach code will no longer place unmanaged devices on the
inactiveList the point/question is probably moot!
John