]> git.proxmox.com Git - qemu.git/commit
scsi: do not return short responses for emulated commands
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 10 Oct 2012 10:18:03 +0000 (12:18 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 12 Nov 2012 14:00:27 +0000 (15:00 +0100)
commitc8dcb531bcd37a4a81d2cc08a89fcd19c34348f9
treec1721b0421027780d7c6e21e32cbd47fa5f66a56
parent3c5645fab3c4b65d0cffbe1aaafc787e4be63d0f
scsi: do not return short responses for emulated commands

The inquiry command, for the case of VPD=1, was returning short
responses; the number of returned bytes was just the number of bytes
in the request, without padding to the specified allocation length
with zero bytes.  This is usually harmless, but it is a violation
of the SCSI specification.

To fix this, always pad with zero bytes to r->cmd.xfer in
scsi_disk_emulate_command, and return at most r->buflen bytes
(the size of the buffer for command data) rather than at most
buflen bytes (the number of bytes that was filled in).

Before this patch, "strace sg_inq -p0x83 /dev/sda" would report a
non-zero resid value.  After this patch, it reports resid=0.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/scsi-disk.c