virtio-serial: fix virtio-serial 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-serial 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
4f456d8025
commit
e77ca8b92a
@ -227,6 +227,7 @@ static void s390_virtio_serial_instance_init(Object *obj)
|
||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SERIAL);
|
||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||
object_unref(OBJECT(&dev->vdev));
|
||||
}
|
||||
|
||||
static int s390_virtio_scsi_init(VirtIOS390Device *s390_dev)
|
||||
|
@ -853,6 +853,7 @@ static void virtio_ccw_serial_instance_init(Object *obj)
|
||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SERIAL);
|
||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||
object_unref(OBJECT(&dev->vdev));
|
||||
}
|
||||
|
||||
static int virtio_ccw_balloon_init(VirtioCcwDevice *ccw_dev)
|
||||
|
@ -1410,6 +1410,7 @@ static void virtio_serial_pci_instance_init(Object *obj)
|
||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SERIAL);
|
||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||
object_unref(OBJECT(&dev->vdev));
|
||||
}
|
||||
|
||||
static const TypeInfo virtio_serial_pci_info = {
|
||||
|
Loading…
Reference in New Issue
Block a user