]> git.proxmox.com Git - mirror_qemu.git/commit
hw/scsi: centralize SG_IO calls into single function
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Wed, 27 Jun 2018 17:24:31 +0000 (14:24 -0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 29 Jun 2018 11:02:50 +0000 (13:02 +0200)
commita0c7e35b17b3d2cade8a5fc8e57904e02fb91fe4
treef0dc2b6caa0729789ee72029191a34bd74069d15
parent0a96ca2437646bad197b0108c5f4a93e7ead05a9
hw/scsi: centralize SG_IO calls into single function

For the VPD Block Limits emulation with SCSI passthrough,
we'll issue an Inquiry request with EVPD set to retrieve
the available VPD pages of the device. This would be done in
a way similar of what scsi_generic_read_device_identification
does: create a SCSI command and a reply buffer, fill in the
sg_io_hdr_t structure, call blk_ioctl, check if an error
occurred, process the response.

This same process is done in other 2 functions, get_device_type
and get_stream_blocksize. They differ in the command/reply
buffer and post-processing, everything else is almost a
copy/paste.

Instead of adding a forth copy/pasted-ish code when adding
the passthrough VPD BL emulation, this patch extirpates
this repetition of those 3 functions and put it into
a new one called scsi_SG_IO_FROM_DEV. Any future code that
wants to execute an SG_DXFER_FROM_DEV to the device can
use it, avoiding filling sg_io_hdr_t again and et cetera.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20180627172432.11120-3-danielhb413@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/scsi/scsi-disk.c
hw/scsi/scsi-generic.c
include/hw/scsi/scsi.h