]> git.proxmox.com Git - mirror_qemu.git/blobdiff - block.c
block: Prepare for NULL BDS
[mirror_qemu.git] / block.c
diff --git a/block.c b/block.c
index e28a32a201cd4347a6b8cf9d965d396b2ea85c64..e9f40dc76836c3ef91ca2cbee44ee5b6c149c554 100644 (file)
--- 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);
         }
     }