[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-stable] [Qemu-devel] [PATCH v2] virtio: Move memory_listener_u
From: |
Fam Zheng |
Subject: |
Re: [Qemu-stable] [Qemu-devel] [PATCH v2] virtio: Move memory_listener_unregister to .unrealize |
Date: |
Wed, 17 May 2017 20:00:41 +0800 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
On Wed, 05/17 02:58, Paolo Bonzini wrote:
> The child property is deleted when bus_unparent calls object_unparent:
>
> while ((kid = QTAILQ_FIRST(&bus->children)) != NULL) {
> DeviceState *dev = kid->child;
> object_unparent(OBJECT(dev));
> }
>
> and in turn bus_unparent is called by the VirtIOSCSIPCI's unparent
> callback (device_unparent):
>
> while (dev->num_child_bus) {
> bus = QLIST_FIRST(&dev->child_bus);
> object_unparent(OBJECT(bus));
> }
OK, sorry for being dumb, these are way over my head. Let me try again:
I count three references before unplug:
a.1) object_property_add_child in virtio_instance_init_common as virtio-backend
a.2) qdev_set_parent_bus in virtio_scsi_pci_realize by virtio-pci-bus
a.3) qbus_set_hotplug_handler in virtio_scsi_device_realize for
Only two object_unref()'s happen in unplug, respectively:
b.1) object_finalize_child_property, matches a.1)
b.2) bus_remove_child, matches a.2)
Do we need cleanup for a.3) ? The patch below does fix the crash for me.
---
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 46a3e3f..fde1b1fe 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -918,6 +918,8 @@ void virtio_scsi_common_unrealize(DeviceState *dev, Error
**errp)
static void virtio_scsi_device_unrealize(DeviceState *dev, Error **errp)
{
+ VirtIOSCSI *s = VIRTIO_SCSI(dev);
+ qbus_set_hotplug_handler(BUS(&s->bus), NULL, &error_abort);
virtio_scsi_common_unrealize(dev, errp);
}
- [Qemu-stable] [PATCH v2] virtio: Move memory_listener_unregister to .unrealize, Fam Zheng, 2017/05/16
- Re: [Qemu-stable] [Qemu-devel] [PATCH v2] virtio: Move memory_listener_unregister to .unrealize, Fam Zheng, 2017/05/16
- Re: [Qemu-stable] [Qemu-devel] [PATCH v2] virtio: Move memory_listener_unregister to .unrealize, Paolo Bonzini, 2017/05/16
- Re: [Qemu-stable] [Qemu-devel] [PATCH v2] virtio: Move memory_listener_unregister to .unrealize, Fam Zheng, 2017/05/16
- Re: [Qemu-stable] [Qemu-devel] [PATCH v2] virtio: Move memory_listener_unregister to .unrealize, Paolo Bonzini, 2017/05/16
- Re: [Qemu-stable] [Qemu-devel] [PATCH v2] virtio: Move memory_listener_unregister to .unrealize, Fam Zheng, 2017/05/16
- Re: [Qemu-stable] [Qemu-devel] [PATCH v2] virtio: Move memory_listener_unregister to .unrealize, Paolo Bonzini, 2017/05/17
- Re: [Qemu-stable] [Qemu-devel] [PATCH v2] virtio: Move memory_listener_unregister to .unrealize,
Fam Zheng <=
- Re: [Qemu-stable] [Qemu-devel] [PATCH v2] virtio: Move memory_listener_unregister to .unrealize, Paolo Bonzini, 2017/05/17