[libvirt] [PATCH v2 4/9] hostdev: Add virHostdevOnlyDetachPCIDevice()

Andrea Bolognani abologna at redhat.com
Wed Jan 27 17:46:56 UTC 2016


On Tue, 2016-01-26 at 18:58 -0500, John Ferlan wrote:
> 
> > -    while (virPCIDeviceListCount(pcidevs) > 0)
> > -        virPCIDeviceListStealIndex(pcidevs, 0);
> > -
> 
> Hmmm.. interesting looks like this would have been a memory leak since
> the code ignoree the return....  Normal when *Steal is called from
> *ListDel, a *DeviceFree is called on the returned stolen device.

I don't think it was, because earlier on the devices in 'pcidevs' are
added, not copied, to the active list. So stealing all of them
from 'pcidevs' here is a way to prevent 'virObjectUnref(pcidevs)' in
the cleanup part to free the memory associated with them

Cheers.

-- 
Andrea Bolognani
Software Engineer - Virtualization Team




More information about the libvir-list mailing list