virtio-pci: reset all qbuses too when writing to the status field

virtio-pci devices do not perform a full reset when zero is written
to the status byte.  While PCI-specific status is initialized, the
reset does not propagate down the qdev bus hierarchy.  Because of
this, a virtio reset does not cancel in-flight I/O for virtio-scsi
(where the cancellation is handled automatically by the SCSI
devices underneath virtio-scsi-pci).

Reported-by: Bryan Venteicher <bryanv@daemoninthecloset.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virtio-s390: reset all qbuses too when writing to the status field

virtio-s390 devices do not perform a full reset when zero is written
to the status byte.  The reset does not propagate down the qdev bus
hierarchy.  Because of this, a virtio reset does not cancel in-flight
I/O for virtio-scsi.

Reported-by: Bryan Venteicher <bryanv@daemoninthecloset.org>
Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
iscsi: add iscsi_create support

This patch adds support for bdrv_create. This allows e.g.
to use qemu-img to convert from any supported device to
an iscsi backed storage as destination.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Signed-off-by: Peter Lieven <pl@dlhnet.de>
iscsi: partly avoid iovec linearization in iscsi_aio_writev

libiscsi expects all write16 data in a linear buffer. If the
iovec only contains one buffer we can skip the linearization
step as well as the additional malloc/free and pass the
buffer directly.

Reported-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: Peter Lieven <pl@kamp.de>

Signed-off-by: Peter Lieven <pl@dlhnet.de>
block: do not probe zero-sized disks

A blank CD or DVD is visible as a zero-sized disks.  Probing such
disks will lead to an EIO and a failure to start the VM.  Treating
them as raw is a better solution.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
lsi: trigger bad phase jump even in the middle of SCRIPTS

A bad phase will always cause an interrupt right now, even if it
happens in the middle of SCRIPTS execution.  Instead, it should
trigger a phase jump according to the datasheet.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi: add transport in SCSIBusInfo

The transport type needs to be known for some commands.  We will start
with a simple case, INQUIRY.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi: report per-target control mode page values correctly and uniformly

Some bits of the control mode page may be different between scsi-generic
and real hardware, so we have to force them to specific values.  In
particular, UA_INTLCK_CTRL is either 00b or 10b depending on what is
more practical for the current HBA.  Add a way to patch the mode data,
and include the correct value of these bits.

The queue algorithm modifier can also be set.  Non-TCQ adaptors (including
USB bulk-only transfer) will never reorder commands, others may.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi: move handling of Sync and TCQ bits to scsi-bus

Handle Sync and TCQ by patching the INQUIRY output, so that it can be
correct for scsi-generic too.  Use the newly added transport field so
that only SPI adapters report Sync=1.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi: report TAS=0, do not report TASK ABORTED

Another mode value that differs under emulation is TAS, which is 1 if
commands aborted from another I_T nexus are completed with a
TASK_ABORTED status.  We usually do not care, because we implement
a single I_T nexus.

However, TASK ABORTED status might happen if we do SCSI passthrough, and
we want to change it to a cancellation so that we "enforce" TAS=0.

This unfortunately makes for an ugly API name.  scsi_req_abort should
really be called scsi_req_cancel (since it cancels I/O); scsi_req_cancel
should really be called scsi_req_abort (since it aborts a command).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi-generic: report aborted commands

Aborted commands can be completed with a TASK_ABORTED status.  This will
be handled in scsi-bus and properly reported by the HBA.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi: introduce scsi_parse_sense

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi-generic: implement rerror/werror

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi: report unit attention on hotplug

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi-disk: implement WRITE SAME

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>