virtio-balloon: fix virtio-balloon child refcount in transports
object_initialize() leaves the object with a refcount of 1. object_property_add_child() adds its own reference which is dropped again when the property is deleted. The upshot of this is that we always have a refcount >= 1. Upon hot unplug the virtio-balloon child is not finalized! Drop our reference after the child property has been added to the parent. Signed-off-by: Gonglei <arei.gonglei@huawei.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
352fa88dfb
commit
91ba212088
@ -900,7 +900,7 @@ static void virtio_ccw_balloon_instance_init(Object *obj)
|
|||||||
VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(obj);
|
VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(obj);
|
||||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BALLOON);
|
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BALLOON);
|
||||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||||
|
object_unref(OBJECT(&dev->vdev));
|
||||||
object_property_add(obj, "guest-stats", "guest statistics",
|
object_property_add(obj, "guest-stats", "guest statistics",
|
||||||
balloon_ccw_stats_get_all, NULL, NULL, dev, NULL);
|
balloon_ccw_stats_get_all, NULL, NULL, dev, NULL);
|
||||||
|
|
||||||
|
@ -1325,7 +1325,7 @@ static void virtio_balloon_pci_instance_init(Object *obj)
|
|||||||
VirtIOBalloonPCI *dev = VIRTIO_BALLOON_PCI(obj);
|
VirtIOBalloonPCI *dev = VIRTIO_BALLOON_PCI(obj);
|
||||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BALLOON);
|
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BALLOON);
|
||||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||||
|
object_unref(OBJECT(&dev->vdev));
|
||||||
object_property_add(obj, "guest-stats", "guest statistics",
|
object_property_add(obj, "guest-stats", "guest statistics",
|
||||||
balloon_pci_stats_get_all, NULL, NULL, dev,
|
balloon_pci_stats_get_all, NULL, NULL, dev,
|
||||||
NULL);
|
NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user