[v2,03/11] block: use refcnt for drive_init/drive_uninit

Submitted by Fam Zheng on July 17, 2013, 9:42 a.m.

Details

Message ID 1374054136-28741-4-git-send-email-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng July 17, 2013, 9:42 a.m.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 blockdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/blockdev.c b/blockdev.c
index c5abd65..bb986a1 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -212,7 +212,7 @@  static void bdrv_format_print(void *opaque, const char *name)
 static void drive_uninit(DriveInfo *dinfo)
 {
     qemu_opts_del(dinfo->opts);
-    bdrv_delete(dinfo->bdrv);
+    bdrv_unref(dinfo->bdrv, false);
     g_free(dinfo->id);
     QTAILQ_REMOVE(&drives, dinfo, next);
     g_free(dinfo->serial);
@@ -709,8 +709,10 @@  DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
         goto err;
     }
 
-    if (bdrv_key_required(dinfo->bdrv))
+    bdrv_ref(dinfo->bdrv, false);
+    if (bdrv_key_required(dinfo->bdrv)) {
         autostart = 0;
+    }
 
     qemu_opts_del(opts);