From 5433c24f0f9306c82ad9bcc2b2b586e5f0ed8fa5 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Mon, 19 Oct 2015 17:53:29 +0200 Subject: 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 Signed-off-by: Kevin Wolf --- migration/block.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'migration/block.c') diff --git a/migration/block.c b/migration/block.c index ed865ed23b..f7bb1e0126 100644 --- a/migration/block.c +++ b/migration/block.c @@ -808,6 +808,11 @@ static int block_load(QEMUFile *f, void *opaque, int version_id) return -EINVAL; } bs = blk_bs(blk); + if (!bs) { + fprintf(stderr, "Block device %s has no medium\n", + device_name); + return -EINVAL; + } if (bs != bs_prev) { bs_prev = bs; -- cgit v1.2.1