Patchwork [04/11] scsi: Reject unimplemented error actions

login
register
mail settings
Submitter Markus Armbruster
Date June 30, 2010, 11:55 a.m.
Message ID <1277898942-6501-5-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/57397/
State New
Headers show

Comments

Markus Armbruster - June 30, 2010, 11:55 a.m.
drive_init() doesn't permit rerror for if=scsi, but that's worthless:
we get it via if=none and -device.

Moreover, scsi-generic doesn't support werror.  Since drive_init()
doesn't catch that, option werror was silently ignored even with
if=scsi.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/scsi-disk.c    |    5 +++++
 hw/scsi-generic.c |    9 +++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
Kevin Wolf - July 5, 2010, 3:39 p.m.
Am 30.06.2010 13:55, schrieb Markus Armbruster:
> drive_init() doesn't permit rerror for if=scsi, but that's worthless:
> we get it via if=none and -device.
> 
> Moreover, scsi-generic doesn't support werror.  Since drive_init()
> doesn't catch that, option werror was silently ignored even with
> if=scsi.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

It's still not entirely right, of course. You can explicitly request
werror=enospc and the VM will start successfully, but silently ignore
ENOSPC errors.

Anyway, it's better than before.

Kevin
Markus Armbruster - July 5, 2010, 4:26 p.m.
Kevin Wolf <kwolf@redhat.com> writes:

> Am 30.06.2010 13:55, schrieb Markus Armbruster:
>> drive_init() doesn't permit rerror for if=scsi, but that's worthless:
>> we get it via if=none and -device.
>> 
>> Moreover, scsi-generic doesn't support werror.  Since drive_init()
>> doesn't catch that, option werror was silently ignored even with
>> if=scsi.
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>
> It's still not entirely right, of course. You can explicitly request
> werror=enospc and the VM will start successfully, but silently ignore
> ENOSPC errors.

Yes, I took a shortcut here :)

Obvious fix is a separate default action.  Drivers supporting werror
interpret it as "enospc".  Drivers not supporting werror interpret it as
"do nothing", and reject any other option.  Similar for rerror.

> Anyway, it's better than before.

Patch

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 3e41011..c30709c 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 (bdrv_get_on_error(s->bs, 1) != BLOCK_ERR_REPORT) {
+        error_report("Device doesn't support drive option rerror");
+        return -1;
+    }
+
     if (!s->serial) {
         /* try to fall back to value set with legacy -drive serial=... */
         dinfo = drive_get_by_blockdev(s->bs);
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index 3915e78..a8b4176 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -474,6 +474,15 @@  static int scsi_generic_initfn(SCSIDevice *dev)
         return -1;
     }
 
+    if (bdrv_get_on_error(s->bs, 0) != BLOCK_ERR_STOP_ENOSPC) {
+        error_report("Device doesn't support drive option werror");
+        return -1;
+    }
+    if (bdrv_get_on_error(s->bs, 1) != BLOCK_ERR_REPORT) {
+        error_report("Device doesn't support drive option rerror");
+        return -1;
+    }
+
     /* check we are using a driver managing SG_IO (version 3 and after */
     if (bdrv_ioctl(s->bs, SG_GET_VERSION_NUM, &sg_version) < 0 ||
         sg_version < 30000) {