mirror of https://gitee.com/openkylin/qemu.git
virtio: fix virtio-blk 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-blk child is not finalized! Drop our reference after the child property has been added to the parent. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
This commit is contained in:
parent
f7fedda84a
commit
c5d49db446
|
@ -179,6 +179,7 @@ static void s390_virtio_blk_instance_init(Object *obj)
|
|||
VirtIOBlkS390 *dev = VIRTIO_BLK_S390(obj);
|
||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BLK);
|
||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||
object_unref(OBJECT(&dev->vdev));
|
||||
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||
}
|
||||
|
||||
|
|
|
@ -813,6 +813,7 @@ static void virtio_ccw_blk_instance_init(Object *obj)
|
|||
VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(obj);
|
||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BLK);
|
||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||
object_unref(OBJECT(&dev->vdev));
|
||||
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||
}
|
||||
|
||||
|
|
|
@ -1101,6 +1101,7 @@ static void virtio_blk_pci_instance_init(Object *obj)
|
|||
VirtIOBlkPCI *dev = VIRTIO_BLK_PCI(obj);
|
||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BLK);
|
||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||
object_unref(OBJECT(&dev->vdev));
|
||||
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue