xen-block: Fix removal of backend instance via xenstore
authorAnthony PERARD <anthony.perard@citrix.com>
Mon, 8 Mar 2021 14:32:32 +0000 (14:32 +0000)
committerSoonKyu Park <sk7.park@samsung.com>
Tue, 23 Nov 2021 04:45:41 +0000 (13:45 +0900)
commitb54cea53d28604330c638b237f69271ae70339ee
tree839a3349000da7c9837dd033f26296397e649997
parent60c832e4f6af2b31a45c84427abd25953088f47a
xen-block: Fix removal of backend instance via xenstore

Git-commit: b807ca3fa0ca29ec015adcf4045e716337cd3635

Whenever a Xen block device is detach via xenstore, the image
associated with it remained open by the backend QEMU and an error is
logged:
    qemu-system-i386: failed to destroy drive: Node xvdz-qcow2 is in use

This happened since object_unparent() doesn't immediately frees the
object and thus keep a reference to the node we are trying to free.
The reference is hold by the "drive" property and the call
xen_block_drive_destroy() fails.

In order to fix that, we call drain_call_rcu() to run the callback
setup by bus_remove_child() via object_unparent().

Fixes: 2d24a6466154 ("device-core: use RCU for list of children of a bus")

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Message-Id: <20210308143232.83388-1-anthony.perard@citrix.com>
Signed-off-by: Bruce Rogers <brogers@suse.com>
hw/block/xen-block.c