Merge pull request #62 from bonzini/master

MD5 updates
Add a version descriptor
TESTS: keep the unmarshalled std inq structure around
TESTS: *protect field set to non-zero are only guaranteed to fail if the device does not support protection information
TESTS: Update the protection tests
TEST: Add a test for inquiry version descriptors

Block devices should claim at least some version of SPC and SBC
SCSI: add a safe function to read a byte from the datain buffer and use it
throughout the unmarshalling code
TESTS: Add a test to start verifying that the BlockLimits VPD page is correct.

Verify that the page length matches up with the size of the data in buffer.
Verify that page length is 0x3c if the device claims SBC-3,  and 0x0c if not.

If the device claims SBC-3 and if it claims UNMAP support (LBPU)
then we check that both MAXIMUM UNMAP LBA COUNT and
MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT looks sane.
Sane here means >0, <1M or 0xffffffff

If the device claims SBC-3 and if it does not claim UNMAP support (LBPU)
then we check that both MAXIMUM UNMAP LBA COUNT and
MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT are both 0.
TESTS: ReadCapacity16 is also mandatory in SBC-2 when INQ->PROTECT is set.
Check for this in the support functions and return error.
TEST: Add test for the protection information setting in READCAPACITY16

If the device does not support PI (INQ->PROTECT) then
verify that PROT_EN, P_TYPE and P_I_EXP are all zero.

If the device does support PI and IF PROT_EN is clear
then verify that both P_TYPE and P_I_EXP are zero.

If the device does support PI and IF PROT_EN is set
then verify that P_TYPE is 0, 1 or 2
TESTS: Keep the LogicalBlockProvisioning VPD around after we read it during
test startup.
TESTS: Make READCAPACITY16PI test more verbose under -V
TESTS: Relax the tests for BlockLimit VPD page length.
Discussions on linux-scsi indicate that some SBC-2 devices may provide
some SBC-3 features and thus a SBC-3 BlockLimit page.

Supporting more than you claim is a transgression but a relatively minor
one, so lets turn a blind eye to it.
Supporting less than you claim is a serious transgression and will always
result in a harsh test failure.
TESTS: BlockLimits VPD. If a device returns a SBC-3 VPD (page length 0x3c)
but does not claim SBC-3 support then print a harsh warning
about this.
TEST: Add SCSI.Unmap.UnmapVPD and see if UNMAP availability matches
the VPD settings.

If UNMAP is not available then LBPU must be clear
and if UNMAP is available then both LBPME and LBPU must be set.
TESTS: Add tests for WriteSame10/16 UNMAP.
If UNMAP is available, verify that both LBPME and LBPWS[10] are set.
If unmap is not available, verify that LBPWS[10] is clear.
TESTS: Fix trying to free a NULL task.
TESTS: UNMAP/WRITESAME10/16 Check LBPRZ before we read the unmapped blocks and verify they are blank.
TESTS: Test that WRITESAME10/16 unmap can handle big number of logical blocks when unmapping.

If  BLockLimits->MaxWriteSameLength is 0 (no limit) or >=256
then verify that both WRITESAME10 and WRITESAME16 can unmap with a
number of blocks == 2 byte field.
If not, then verify that a 256 block unmap results in INVALID FIELD IN CDB

If  BLockLimits->MaxWriteSameLength is 0 (no limit) or >=65536
then verify that WRITESAME16 can unmap with a
number of blocks == 3 byte field.
If not, then verify that a 65536 block unmap results in INVALID FIELD IN CDB

From discussions on linux-scsi there are devices that support WRITESAME16
but where the implementation only looks at the low 2 bytes of the 4 bytes for
num-blocks in the CDB.
This added test aims to find and flag such devices.
TESTS: Writesame16_unmap test should call writesame16  not writesame10