qemu-patch-raspberry4/hw/core
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
..
empty_slot.c empty_slot: QOM cast cleanup 2013-07-29 21:06:37 +02:00
hotplug.c define hotplug interface 2014-02-10 10:23:35 +02:00
irq.c hw/core: Add interface to allocate and free a single IRQ 2013-10-14 17:11:44 +03:00
loader.c pc: avoid duplicate names for ROM MRs 2014-03-11 13:25:48 +02:00
machine.c hw/core: Introduce QEMU machine as QOM object 2014-03-12 20:13:02 +01:00
Makefile.objs hw/core: Introduce QEMU machine as QOM object 2014-03-12 20:13:02 +01:00
null-machine.c hw: Clean up bogus default boot order 2013-08-28 10:16:47 +03:00
ptimer.c aio / timers: Switch entire codebase to the new timer API 2013-08-22 19:14:24 +02:00
qdev-properties-system.c iothread: add "iothread" qdev property type 2014-03-13 14:42:24 +01:00
qdev-properties.c qdev: Use QAPI type names for properties 2014-02-14 21:12:05 +01:00
qdev.c qom: Make QOM link property unref optional 2014-03-19 22:05:20 +01:00
stream.c stream: Remove app argument hack 2013-04-16 10:04:23 +02:00
sysbus.c sysbus: Set cannot_instantiate_with_device_add_yet 2013-12-23 00:27:22 +01:00
uboot_image.h hw: move private headers to hw/ subdirectories. 2013-04-08 18:13:16 +02:00