summary refs log tree commit diff stats
path: root/hw/virtio-blk.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/virtio-blk.c')
-rw-r--r--hw/virtio-blk.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 99e9dd294b..f50069d20b 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -495,6 +495,10 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf)
         error_report("virtio-blk-pci: drive property not set");
         return NULL;
     }
+    if (!bdrv_is_inserted(conf->bs)) {
+        error_report("Device needs media, but drive is empty");
+        return NULL;
+    }
 
     s = (VirtIOBlock *)virtio_common_init("virtio-blk", VIRTIO_ID_BLOCK,
                                           sizeof(struct virtio_blk_config),