For better support for older versions of libiscsi I think it would be good to convert all the iscsi_unmap_task/iscsi_writesame*_task/iscsi_*_task functions with calls to the much more genric iscsi_scsi_command_sync().
iscsi_scsi_command_sync() and iscsi_scsi_command_async() have been available since prior to version 1.1 and can be used to send arbitrary scsi opcodes to the target. iscsi_scsi_command_async() is already used instead of iscs_read16/write16_async() since the read16/write16 helpers were added to libiscsi at a much later stage and there are examples of its use. Using iscsi_scsi_command_[a]sync() instead of for example iscsi_unmap_task() would mean that you can use the UNMAP opcode always, regardless version of libiscsi. It would mean that you need to build the CDB directly inside block/iscsi.c but that is not hard. I.e. change block/iscsi.c to only use iscsi_scsi_command_[a]sync() for all opcodes it wants to send to the target. On Wed, Nov 6, 2013 at 1:16 PM, Paolo Bonzini <pbonz...@redhat.com> wrote: > Il 06/11/2013 20:38, Peter Lieven ha scritto: >> >> Am 06.11.2013 um 14:09 schrieb Paolo Bonzini <pbonz...@redhat.com>: >> >>> Il 06/11/2013 14:08, Stefan Hajnoczi ha scritto: >>>> Thanks, applied to my block-next tree: >>>> https://github.com/stefanha/qemu/commits/block-next >>>> >>>> This will go into QEMU 1.8. Since it's a new feature that touches core >>>> block layer code and several block drivers, I can't merge it into >>>> 1.7-rc. >>> >>> Yay! With these patches I can properly emulate WRITE SAME in the SCSI >>> layer. >> >> Yes, you can, but only when write same is used to write zeroes. The other >> case is still unhandled or needs emulation. > > WRITE SAME with UNMAP is incorrect in the current QEMU code. Your patch > let me fix it so that the payload can be read back with no change, *and* > sectors are unmapped when possible. > > Paolo >