aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi/scsi-disk.c
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2018-03-28 00:41:41 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2018-04-09 16:36:39 +0200
commit37c51741892a89cf5710f5ac231091fb0a6352c7 (patch)
treee1e99894e34497941e19cc83f87d9c52d1aa10d4 /hw/scsi/scsi-disk.c
parentdb1b5f135c58a1473b6609b53b8fd9da02d6b5d1 (diff)
scsi-disk: Don't enlarge min_io_size to max_io_size
Some backends report big max_io_sectors. Making min_io_size the same value in this case will make it impossible for guest to align memory, therefore the disk may not be usable at all. Do not enlarge them when they are zero. Reported-by: David Gibson <dgibson@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Message-Id: <20180327164141.19075-1-famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/scsi/scsi-disk.c')
-rw-r--r--hw/scsi/scsi-disk.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index f5ab767ab5..f8ed8cf2b4 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -714,10 +714,12 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)
/* min_io_size and opt_io_size can't be greater than
* max_io_sectors */
- min_io_size =
- MIN_NON_ZERO(min_io_size, max_io_sectors);
- opt_io_size =
- MIN_NON_ZERO(opt_io_size, max_io_sectors);
+ if (min_io_size) {
+ min_io_size = MIN(min_io_size, max_io_sectors);
+ }
+ if (opt_io_size) {
+ opt_io_size = MIN(opt_io_size, max_io_sectors);
+ }
}
/* required VPD size with unmap support */
buflen = 0x40;