summaryrefslogtreecommitdiffstats
path: root/block.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2015-10-19 17:53:29 +0200
committerKevin Wolf <kwolf@redhat.com>2015-10-23 18:18:23 +0200
commit5433c24f0f9306c82ad9bcc2b2b586e5f0ed8fa5 (patch)
tree8b2eb29767ef12bf28d528050a0463b3e9458f5b /block.c
parent0c3c36d651922ebe9244e68e6d9ed14cdfcac9fd (diff)
downloadhqemu-5433c24f0f9306c82ad9bcc2b2b586e5f0ed8fa5.zip
hqemu-5433c24f0f9306c82ad9bcc2b2b586e5f0ed8fa5.tar.gz
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.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/block.c b/block.c
index e28a32a..e9f40dc 100644
--- a/block.c
+++ b/block.c
@@ -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);
}
}
OpenPOWER on IntegriCloud