[libvirt] [PATCH 05/22] pci: make virPCIDeviceDetach consistent in behavior

Daniel P. Berrange berrange at redhat.com
Mon Jun 24 14:57:45 UTC 2013


On Mon, Jun 24, 2013 at 05:54:54AM -0400, Laine Stump wrote:
> virPCIDeviceDetach would previously sometimes consume the input device
> object (to put it on the inactive list) and sometimes not. Avoiding
> memory leaks required checking beforehand to see if the device was
> already on the list, and freeing the device object in the caller only
> if there wasn't already an identical object on the inactive list.
> 
> This patch makes it consistent - virPCIDeviceDetach will *never*
> consume the input virPCIDevice object; if it needs to put one on the
> inactive list, it will create a copy and put *that* on the list. This
> way the caller knows that it is always their responsibility to free
> the device object they created.
> ---
>  src/qemu/qemu_driver.c |  8 +++-----
>  src/util/virpci.c      | 26 ++++++++++++++++++++++++--
>  2 files changed, 27 insertions(+), 7 deletions(-)

ACK much safer semantics.


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list