qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] virtio: Move memory_listener_unregister to .


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v2] virtio: Move memory_listener_unregister to .unrealize
Date: Tue, 16 May 2017 14:44:37 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0


On 16/05/2017 14:25, Fam Zheng wrote:
> You are right. Having had another look, I think it's because of this:
> VirtIODevice is an embeded member of VirtIOSCSIPCI therefore it is never
> "finalized" through QOM reference directly.  Am I right?

What I would expect is:

virtio_instance_init_common:
- create the VirtIODevice with refcount 1
- create a child property for the VirtIODevice (refcount is now 2)
- unref the VirtIODevice (refcount is again 1)

virtio_pci_realize:
- virtio_pci_bus_new creates the virtio bus
- the virtio bus is added as a child property

virtio_scsi_pci_realize:
- qdev_set_parent_bus links the device to the bus (bus and VirtIODevice
refcounts are now 3)
- the VirtIODevice is realized

...
at hot-unplug time:
- the device is unrealized
- the bus is unparented (calling bus_unparent)
  - the device is unparented (calling device_unparent)
    - bus_remove_child is called (bus and VirtIODevice refcounts are now 1)
    - the VirtIODevice child property is deleted by object_unparent and
the VirtIODevice is finalized
  - the bus child property is deleted by object_unparent and the
VirtIODevice is finalized

Thanks,

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]