summaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-10-07 13:59:08 +0200
committerKevin Wolf <kwolf@redhat.com>2014-10-20 13:41:26 +0200
commit9ba10c95a4a63ef453893ba16bf1c8e11a1d3c39 (patch)
treeeffe1e5953818f0965be290de0748b5516e7015a /blockdev.c
parent8fb3c76c949f34f29c5252ee339fbe1cbfcc3234 (diff)
block: Make BlockBackend own its BlockDriverState
On BlockBackend destruction, unref its BlockDriverState. Replaces the callers' unrefs. This turns the pointer from BlockBackend to BlockDriverState into a strong reference, managed with bdrv_ref() / bdrv_unref(). The back-pointer remains weak. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/blockdev.c b/blockdev.c
index a00461df7b..63f797b417 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -278,10 +278,7 @@ static void bdrv_format_print(void *opaque, const char *name)
void drive_del(DriveInfo *dinfo)
{
- BlockBackend *blk = dinfo->bdrv->blk;
-
- bdrv_unref(dinfo->bdrv);
- blk_unref(blk);
+ blk_unref(dinfo->bdrv->blk);
}
typedef struct {
@@ -583,7 +580,6 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
return blk;
err:
- bdrv_unref(bs);
blk_unref(blk);
early_err:
qemu_opts_del(opts);
@@ -2608,7 +2604,6 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
}
if (bdrv_key_required(blk_bs(blk))) {
- bdrv_unref(blk_bs(blk));
blk_unref(blk);
error_setg(errp, "blockdev-add doesn't support encrypted devices");
goto fail;