virtio-rng: fix virtio-rng 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-rng 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
8ee486ae33
commit
352fa88dfb
|
@ -312,6 +312,7 @@ static void s390_virtio_rng_instance_init(Object *obj)
|
||||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
|
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
|
||||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||||
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||||
|
object_unref(OBJECT(&dev->vdev));
|
||||||
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
|
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
|
||||||
(Object **)&dev->vdev.conf.rng,
|
(Object **)&dev->vdev.conf.rng,
|
||||||
qdev_prop_allow_set_link_before_realize,
|
qdev_prop_allow_set_link_before_realize,
|
||||||
|
|
|
@ -1543,6 +1543,7 @@ static void virtio_ccw_rng_instance_init(Object *obj)
|
||||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
|
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
|
||||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||||
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||||
|
object_unref(OBJECT(&dev->vdev));
|
||||||
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
|
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
|
||||||
(Object **)&dev->vdev.conf.rng,
|
(Object **)&dev->vdev.conf.rng,
|
||||||
qdev_prop_allow_set_link_before_realize,
|
qdev_prop_allow_set_link_before_realize,
|
||||||
|
|
|
@ -1525,6 +1525,7 @@ static void virtio_rng_initfn(Object *obj)
|
||||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
|
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
|
||||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||||
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||||
|
object_unref(OBJECT(&dev->vdev));
|
||||||
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
|
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
|
||||||
(Object **)&dev->vdev.conf.rng,
|
(Object **)&dev->vdev.conf.rng,
|
||||||
qdev_prop_allow_set_link_before_realize,
|
qdev_prop_allow_set_link_before_realize,
|
||||||
|
|
Loading…
Reference in a new issue