blk_by_name() may return a BlockBackend for which blk_bs() returns NULL. In this case, an error should be returned (instead of just returning NULL without modifying *errp).
Signed-off-by: Max Reitz <mre...@redhat.com> --- block.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block.c b/block.c index 9a0a510..b7e631c 100644 --- a/block.c +++ b/block.c @@ -3718,6 +3718,11 @@ BlockDriverState *bdrv_lookup_bs(const char *device, blk = blk_by_name(device); if (blk) { + if (!blk_bs(blk)) { + error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); + return NULL; + } + return blk_bs(blk); } } -- 2.1.0