• D
    hw/scsi: centralize SG_IO calls into single function · a0c7e35b
    Daniel Henrique Barboza 提交于
    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: NDaniel Henrique Barboza <danielhb413@gmail.com>
    Message-Id: <20180627172432.11120-3-danielhb413@gmail.com>
    Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
    a0c7e35b
scsi-generic.c 17.5 KB