Commit 0c3c36d6 authored by Max Reitz's avatar Max Reitz Committed by Kevin Wolf
Browse files

block: Add blk_insert_bs()



This function associates the given BlockDriverState with the given
BlockBackend.

Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent a46fc9c9
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -333,6 +333,17 @@ void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk)
    }
}

/*
 * Associates a new BlockDriverState with @blk.
 */
void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs)
{
    assert(!blk->bs && !bs->blk);
    bdrv_ref(bs);
    blk->bs = bs;
    bs->blk = blk;
}

/*
 * Attach device model @dev to @blk.
 * Return 0 on success, -EBUSY when a device model is attached already.
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ BlockBackend *blk_by_name(const char *name);
BlockBackend *blk_next(BlockBackend *blk);

BlockDriverState *blk_bs(BlockBackend *blk);
void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs);

void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk);