qemu/hw/dma
Stefan Hajnoczi 9561fda8d9 qom: Make QOM link property unref optional
Some object_property_add_link() callers expect property deletion to
unref the link property object.  Other callers expect to manage the
refcount themselves.  The former are currently broken and therefore leak
the link property object.

This patch adds a flags argument to object_property_add_link() so the
caller can specify which refcount behavior they require.  The new
OBJ_PROP_LINK_UNREF_ON_RELEASE flag causes the link pointer to be
unreferenced when the property is deleted.

This fixes refcount leaks in qdev.c, xilinx_axidma.c, xilinx_axienet.c,
s390-virtio-bus.c, virtio-pci.c, virtio-rng.c, and ui/console.c.

Rationale for refcount behavior:

 * hw/core/qdev.c
   - bus children are explicitly unreferenced, don't interfere
   - parent_bus is essentially a read-only property that doesn't hold a
     refcount, don't unref
   - hotplug_handler is leaked, do unref

 * hw/dma/xilinx_axidma.c
   - rx stream "dma" links are set using set_link, therefore they
     need unref
   - tx streams are set using set_link, therefore they need unref

 * hw/net/xilinx_axienet.c
   - same reasoning as hw/dma/xilinx_axidma.c

 * hw/pcmcia/pxa2xx.c
   - pxa2xx bypasses set_link and therefore does not use refcounts

 * hw/s390x/s390-virtio-bus.c
 * hw/virtio/virtio-pci.c
 * hw/virtio/virtio-rng.c
 * ui/console.c
   - set_link is used and there is no explicit unref, do unref

Cc: Peter Crosthwaite <peter.crosthwaite@petalogix.com>
Cc: Alexander Graf <agraf@suse.de>
Cc: Anthony Liguori <aliguori@amazon.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-03-19 22:05:20 +01:00
..
etraxfs_dma.c memory: add owner argument to initialization functions 2013-07-04 17:42:44 +02:00
i8257.c memory: add owner argument to initialization functions 2013-07-04 17:42:44 +02:00
i82374.c qdev: Remove hex8/32/64 property types 2014-02-14 21:12:04 +01:00
Makefile.objs hw: move DMA controllers to hw/dma/, configure with default-configs/ 2013-04-08 18:13:14 +02:00
omap_dma.c hw/dma/omap_dma: Fix bugs with DMA requests above 32 2013-07-15 16:17:44 +01:00
pl080.c exec: Make ldl_*_phys input an AddressSpace 2014-02-11 22:56:54 +10:00
pl330.c dma/pl330: implement dmaadnh instruction 2014-02-26 17:20:09 +00:00
puv3_dma.c puv3_dma: QOM cast cleanup 2013-07-29 21:06:45 +02:00
pxa2xx_dma.c pxa2xx_dma: QOM cast cleanup 2013-07-29 21:06:45 +02:00
rc4030.c aio / timers: Switch entire codebase to the new timer API 2013-08-22 19:14:24 +02:00
soc_dma.c aio / timers: Switch entire codebase to the new timer API 2013-08-22 19:14:24 +02:00
sparc32_dma.c hw: cannot_instantiate_with_device_add_yet due to pointer props 2013-12-24 17:27:17 +01:00
sun4m_iommu.c qdev: Remove hex8/32/64 property types 2014-02-14 21:12:04 +01:00
xilinx_axidma.c qom: Make QOM link property unref optional 2014-03-19 22:05:20 +01:00