Skip to content

Commit

Permalink
block: Add blk_make_empty()
Browse files Browse the repository at this point in the history
Two callers of BlockDriver.bdrv_make_empty() remain that should not call
this method directly.  Both do not have access to a BdrvChild, but they
can use a BlockBackend, so we add this function that lets them use it.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200429141126.85159-4-mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
XanClic authored and kevmw committed May 18, 2020
1 parent 6f7a3b5 commit 2b7bbdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions block/block-backend.c
Expand Up @@ -2402,3 +2402,13 @@ const BdrvChild *blk_root(BlockBackend *blk)
{
return blk->root;
}

int blk_make_empty(BlockBackend *blk, Error **errp)
{
if (!blk_is_available(blk)) {
error_setg(errp, "No medium inserted");
return -ENOMEDIUM;
}

return bdrv_make_empty(blk->root, errp);
}
2 changes: 2 additions & 0 deletions include/sysemu/block-backend.h
Expand Up @@ -266,4 +266,6 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,

const BdrvChild *blk_root(BlockBackend *blk);

int blk_make_empty(BlockBackend *blk, Error **errp);

#endif

0 comments on commit 2b7bbdb

Please sign in to comment.