qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

block: Add blk_make_empty()

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>

authored by

Max Reitz and committed by
Kevin Wolf
2b7bbdbd 6f7a3b53

+12
+10
block/block-backend.c
··· 2402 2402 { 2403 2403 return blk->root; 2404 2404 } 2405 + 2406 + int blk_make_empty(BlockBackend *blk, Error **errp) 2407 + { 2408 + if (!blk_is_available(blk)) { 2409 + error_setg(errp, "No medium inserted"); 2410 + return -ENOMEDIUM; 2411 + } 2412 + 2413 + return bdrv_make_empty(blk->root, errp); 2414 + }
+2
include/sysemu/block-backend.h
··· 266 266 267 267 const BdrvChild *blk_root(BlockBackend *blk); 268 268 269 + int blk_make_empty(BlockBackend *blk, Error **errp); 270 + 269 271 #endif