Doesn't make a difference just yet, but it's the right thing to do. Signed-off-by: Markus Armbruster <arm...@redhat.com> --- block/block-backend.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/block-backend.c b/block/block-backend.c index 9c504f3..17285ba 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -251,6 +251,7 @@ int blk_attach_dev(BlockBackend *blk, void *dev) if (blk->dev) { return -EBUSY; } + blk_ref(blk); blk->dev = dev; bdrv_iostatus_reset(blk->bs); @@ -279,9 +280,10 @@ void blk_detach_dev(BlockBackend *blk, void *dev) /* TODO change to DeviceState *dev when all users are qdevified */ { assert(blk->dev == dev); - blk->dev = NULL; blk->dev_ops = NULL; blk->dev_opaque = NULL; + blk->dev = NULL; + blk_unref(blk); bdrv_set_guest_block_size(blk->bs, 512); qemu_coroutine_adjust_pool_size(-COROUTINE_POOL_RESERVATION); } -- 1.9.3