qemu-patch-raspberry4/hw/scsi
Greg Kurz 661e32fb3c virtio-scsi: convert virtio_scsi_bad_req() to use virtio_error()
The virtio_scsi_bad_req() function is called when a guest sends a
request with missing or ill-sized headers. This generally happens
when the virtio_scsi_parse_req() function returns an error.

With this patch, virtio_scsi_bad_req() will mark the device as broken,
detach the request from the virtqueue and free it, instead of forcing
QEMU to exit.

In nearly all locations where virtio_scsi_bad_req() is called, the only
thing to do next is to return to the caller.

The virtio_scsi_handle_cmd_req_prepare() function is an exception though.

It is called in a loop by virtio_scsi_handle_cmd_vq() and passed requests
freshly popped from a cmd virtqueue; virtio_scsi_handle_cmd_req_prepare()
does some sanity checks on the request and returns a boolean flag to
indicate whether the request should be queued or not. In the latter case,
virtio_scsi_handle_cmd_req_prepare() has detected a non-fatal error and
sent a response back to the guest.

We have now a new condition to take into account: the device is broken
and should stop all processing.

The return value of virtio_scsi_handle_cmd_req_prepare() is hence changed
to an int. A return value of zero means that the request should be queued.
Other non-fatal error cases where the request shoudn't be queued  return
a negative errno (values are vaguely inspired by the error condition, but
the only goal here is to discriminate the case we're interested in).

And finally, if virtio_scsi_bad_req() was called, -EINVAL is returned. In
this case, virtio_scsi_handle_cmd_vq() detaches and frees already queued
requests, instead of submitting them.

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-10-10 01:16:59 +03:00
..
esp-pci.c include/qemu/osdep.h: Don't include qapi/error.h 2016-03-22 22:20:15 +01:00
esp.c scsi: esp: fix migration 2016-06-29 14:03:47 +02:00
lsi53c895a.c lsi: never set DMA FIFO Empty (DFE) bit in DSTAT register 2016-09-13 19:08:45 +02:00
Makefile.objs hw: Add support for LSI SAS1068 (mptsas) device 2016-02-09 15:45:26 +01:00
megasas.c Revert "megasas: remove useless check for cmd->frame" 2016-09-13 19:09:43 +02:00
mfi.h Clean up header guards that don't match their file name 2016-07-12 16:19:16 +02:00
mpi.h hw: Add support for LSI SAS1068 (mptsas) device 2016-02-09 15:45:26 +01:00
mptconfig.c scsi: mptconfig: fix misuse of MPTSAS_CONFIG_PACK 2016-09-13 19:08:46 +02:00
mptendian.c hw: Add support for LSI SAS1068 (mptsas) device 2016-02-09 15:45:26 +01:00
mptsas.c * Support multiple -d trace:PATTERN arguments (Daniel) 2016-09-15 18:12:40 +01:00
mptsas.h mptsas: really fix migration compatibility 2016-08-03 18:44:56 +02:00
scsi-bus.c scsi-bus: Use longer sense buffer with scanners 2016-07-12 18:31:26 +02:00
scsi-disk.c scsi-disk: Cleaning up around tray open state 2016-09-14 12:25:13 +02:00
scsi-generic.c block: Switch transfer length bounds to byte-based 2016-07-05 16:46:25 +02:00
spapr_vscsi.c spapr_vscsi: fix build error introduced by f19661c8 2016-10-05 11:05:28 +11:00
srp.h spapr-vscsi: add task management 2013-09-12 08:46:21 +02:00
trace-events spapr_vscsi: fix build error introduced by f19661c8 2016-10-05 11:05:28 +11:00
vhost-scsi.c Use #include "..." for our own headers, <...> for others 2016-07-12 16:19:16 +02:00
viosrp.h hw: move private headers to hw/ subdirectories. 2013-04-08 18:13:16 +02:00
virtio-scsi-dataplane.c Use #include "..." for our own headers, <...> for others 2016-07-12 16:19:16 +02:00
virtio-scsi.c virtio-scsi: convert virtio_scsi_bad_req() to use virtio_error() 2016-10-10 01:16:59 +03:00
vmw_pvscsi.c scsi: pvscsi: limit process IO loop to ring size 2016-09-14 12:25:14 +02:00
vmw_pvscsi.h scsi: VMWare PVSCSI paravirtual device implementation 2013-04-19 10:44:17 +02:00