aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi-disk.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2010-07-06 14:37:44 +0200
committerKevin Wolf <kwolf@redhat.com>2010-07-13 17:48:17 +0200
commit98f28ad7a7d26e5e77c5cb37b262d76d6ccd963d (patch)
treea17198bf6887562708d62a0cf13b17777645cd67 /hw/scsi-disk.c
parentd75d25e34e4b4eb6a18122b5fa3baac70cea0f2b (diff)
ide scsi virtio-blk: Reject empty drives unless media is removable
Disks without media make no sense. For SCSI, a Linux guest kernel complains during boot. I didn't try other combinations. scsi-generic doesn't need the additional check, because it already requires bdrv_is_sg(), which fails without media. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/scsi-disk.c')
-rw-r--r--hw/scsi-disk.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index c30709c550..f43f2d097c 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1059,6 +1059,11 @@ static int scsi_disk_initfn(SCSIDevice *dev)
s->bs = s->qdev.conf.bs;
is_cd = bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM;
+ if (!is_cd && !bdrv_is_inserted(s->bs)) {
+ error_report("Device needs media, but drive is empty");
+ return -1;
+ }
+
if (bdrv_get_on_error(s->bs, 1) != BLOCK_ERR_REPORT) {
error_report("Device doesn't support drive option rerror");
return -1;