diff options
author | Gonglei <arei.gonglei@huawei.com> | 2014-09-30 14:10:30 +0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-09-30 11:08:56 +0200 |
commit | 1312f12bcc8911ed99b67227fb9d1607295f71ed (patch) | |
tree | 519cbba8c7ae9d6ca976822db7ba7f197ffceb69 | |
parent | c39343fd811a22c921fc08e9e6ca62c8e7539264 (diff) | |
download | qemu-1312f12bcc8911ed99b67227fb9d1607295f71ed.tar.gz qemu-1312f12bcc8911ed99b67227fb9d1607295f71ed.tar.bz2 qemu-1312f12bcc8911ed99b67227fb9d1607295f71ed.zip |
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>
-rw-r--r-- | hw/s390x/s390-virtio-bus.c | 2 | ||||
-rw-r--r-- | hw/s390x/virtio-ccw.c | 2 | ||||
-rw-r--r-- | hw/virtio/virtio-pci.c | 2 |
3 files changed, 6 insertions, 0 deletions
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c index eaaa275775..42760340f4 100644 --- a/hw/s390x/s390-virtio-bus.c +++ b/hw/s390x/s390-virtio-bus.c @@ -258,6 +258,7 @@ static void s390_virtio_scsi_instance_init(Object *obj) VirtIOSCSIS390 *dev = VIRTIO_SCSI_S390(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); } @@ -280,6 +281,7 @@ static void s390_vhost_scsi_instance_init(Object *obj) VHostSCSIS390 *dev = VHOST_SCSI_S390(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); } #endif diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 458aabc68b..a466674ba7 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -938,6 +938,7 @@ static void virtio_ccw_scsi_instance_init(Object *obj) VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(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); } @@ -960,6 +961,7 @@ static void vhost_ccw_scsi_instance_init(Object *obj) VHostSCSICcw *dev = VHOST_SCSI_CCW(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); } #endif diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index ef48983838..09f209325e 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); } |