From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 5/5] ide scsi virtio-blk: Reject empty drives unless media is removable
Date: Tue, 13 Jul 2010 17:54:26 +0200 [thread overview]
Message-ID: <1279036466-19934-6-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1279036466-19934-1-git-send-email-kwolf@redhat.com>
From: Markus Armbruster <armbru@redhat.com>
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>
---
hw/ide/core.c | 4 ++++
hw/scsi-disk.c | 5 +++++
hw/virtio-blk.c | 4 ++++
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/hw/ide/core.c b/hw/ide/core.c
index af52c2c..e20f2e7 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2630,6 +2630,10 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs,
s->drive_kind = IDE_CD;
bdrv_set_change_cb(bs, cdrom_change_cb, s);
} else {
+ if (!bdrv_is_inserted(s->bs)) {
+ error_report("Device needs media, but drive is empty");
+ return -1;
+ }
if (bdrv_is_read_only(bs)) {
error_report("Can't use a read-only drive");
return -1;
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index c30709c..f43f2d0 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;
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 99e9dd2..f50069d 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),
--
1.7.1.1
next prev parent reply other threads:[~2010-07-13 15:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-13 15:54 [Qemu-devel] [PULL 0/5] Block patches Kevin Wolf
2010-07-13 15:54 ` [Qemu-devel] [PATCH 1/5] qemu-img: Fix copy+paste bug in documentation Kevin Wolf
2010-07-13 15:54 ` [Qemu-devel] [PATCH 2/5] Block migration fail, ignore error from bdrv_getlength Kevin Wolf
2010-07-13 15:54 ` [Qemu-devel] [PATCH 3/5] virtio-pci: Check for virtio_blk_init() failure Kevin Wolf
2010-07-13 15:54 ` [Qemu-devel] [PATCH 4/5] virtio-blk: Fix virtio-blk-s390 to require drive Kevin Wolf
2010-07-13 15:54 ` Kevin Wolf [this message]
2010-07-13 16:43 ` [Qemu-devel] [PULL 0/5] Block patches Brian Jackson
2010-07-13 16:47 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1279036466-19934-6-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).