Doesn't make a difference just yet, but it's the right thing to do.

Signed-off-by: Markus Armbruster <arm...@redhat.com>
Reviewed-by: BenoƮt Canet <benoit.ca...@nodalink.com>
Reviewed-by: Kevin Wolf <kw...@redhat.com>
Reviewed-by: Max Reitz <mre...@redhat.com>
---
 block/block-backend.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/block/block-backend.c b/block/block-backend.c
index bdcbac6..d0692b1 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -257,6 +257,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);
 
@@ -290,6 +291,7 @@ void blk_detach_dev(BlockBackend *blk, void *dev)
     blk->dev_opaque = NULL;
     bdrv_set_guest_block_size(blk->bs, 512);
     qemu_coroutine_adjust_pool_size(-COROUTINE_POOL_RESERVATION);
+    blk_unref(blk);
 }
 
 /*
-- 
1.9.3


Reply via email to