aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2014-09-30 14:10:30 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2014-09-30 11:08:56 +0200
commit1312f12bcc8911ed99b67227fb9d1607295f71ed (patch)
tree519cbba8c7ae9d6ca976822db7ba7f197ffceb69 /hw/virtio
parentc39343fd811a22c921fc08e9e6ca62c8e7539264 (diff)
downloadqemu-1312f12bcc8911ed99b67227fb9d1607295f71ed.zip
qemu-1312f12bcc8911ed99b67227fb9d1607295f71ed.tar.gz
qemu-1312f12bcc8911ed99b67227fb9d1607295f71ed.tar.bz2
virtio/vhost-scsi: fix virtio-scsi/vhost-scsi 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-scsi/vhost-scsi 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>
Diffstat (limited to 'hw/virtio')
-rw-r--r--hw/virtio/virtio-pci.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index ef48983..09f2093 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1186,6 +1186,7 @@ static void virtio_scsi_pci_instance_init(Object *obj)
VirtIOSCSIPCI *dev = VIRTIO_SCSI_PCI(obj);
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SCSI);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+ object_unref(OBJECT(&dev->vdev));
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
}
@@ -1242,6 +1243,7 @@ static void vhost_scsi_pci_instance_init(Object *obj)
VHostSCSIPCI *dev = VHOST_SCSI_PCI(obj);
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VHOST_SCSI);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+ object_unref(OBJECT(&dev->vdev));
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
}