]> git.proxmox.com Git - qemu.git/commitdiff
block: Reset device model callbacks on detach
authorMarkus Armbruster <armbru@redhat.com>
Wed, 20 Jul 2011 16:23:36 +0000 (18:23 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 1 Aug 2011 10:09:11 +0000 (12:09 +0200)
BlockDriverState members change_cb and change_opaque are initially
null.  The device model may set them, with bdrv_set_change_cb().  If
the device model gets detached (hot unplug), they're left dangling.
Only safe because device hot unplug automatically destroys the
BlockDriverState.  But that's a questionable feature, best not to rely
on it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c

diff --git a/block.c b/block.c
index 9549b9eff9f3034fdfae86e239851db459b9c0da..81a82578a21e2c4f7948b40093e09f3301f28336 100644 (file)
--- a/block.c
+++ b/block.c
@@ -730,6 +730,8 @@ void bdrv_detach(BlockDriverState *bs, DeviceState *qdev)
 {
     assert(bs->peer == qdev);
     bs->peer = NULL;
+    bs->change_cb = NULL;
+    bs->change_opaque = NULL;
 }
 
 DeviceState *bdrv_get_attached(BlockDriverState *bs)