diff options
author | Max Reitz <mreitz@redhat.com> | 2015-10-19 17:53:29 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2015-10-23 18:18:23 +0200 |
commit | 5433c24f0f9306c82ad9bcc2b2b586e5f0ed8fa5 (patch) | |
tree | 8b2eb29767ef12bf28d528050a0463b3e9458f5b /block.c | |
parent | 0c3c36d651922ebe9244e68e6d9ed14cdfcac9fd (diff) |
block: Prepare for NULL BDS
blk_bs() will not necessarily return a non-NULL value any more (unless
blk_is_available() is true or it can be assumed to otherwise, e.g.
because it is called immediately after a successful blk_new_with_bs() or
blk_new_open()).
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -2683,6 +2683,11 @@ BlockDriverState *bdrv_lookup_bs(const char *device, blk = blk_by_name(device); if (blk) { + if (!blk_bs(blk)) { + error_setg(errp, "Device '%s' has no medium", device); + return NULL; + } + return blk_bs(blk); } } |