
On Tue, 2016-01-19 at 16:36 +0100, Andrea Bolognani wrote:
This function mirrors reattachPCIDevices().
The handling of active and inactive devices is updated and made more explicit, which means virHostdevPreparePCIDevices() has to be updated as well. --- src/util/virhostdev.c | 125 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 49 deletions(-)
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 74c43f2..2d219dd 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -593,6 +593,56 @@ reattachPCIDevices(virHostdevManagerPtr mgr, return ret; } +/** + * detachPCIDevices: + * @mgr: hostdev manager + * @pcidevs: PCI devices to be detached + * @skipUnmanaged: whether to skip unmanaged devices + * + * Detach PCI devices from the host. + * + * The PCI related parts of @mgr (inactivePCIHostdevs, activePCIHostdevs) + * must have been locked beforehand using virObjectLock(). + * + * Returns: 0 on success, <0 on failure + */ +static int +detachPCIDevices(virHostdevManagerPtr mgr, + virPCIDeviceListPtr pcidevs, + bool skipUnmanaged) +{ + size_t i; + int ret = -1; + + for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) { + virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i); + + /* Skip unmanaged devices if asked to do so */ + if (!virPCIDeviceGetManaged(dev) && skipUnmanaged) { + VIR_DEBUG("Not detaching unmanaged PCI device %s", + virPCIDeviceGetName(dev)); + continue; + } + + VIR_DEBUG("Detaching managed PCI device %s", + virPCIDeviceGetName(dev));
s/managed // Cheers. -- Andrea Bolognani Software Engineer - Virtualization Team