Commit 37c51741 authored by Fam Zheng's avatar Fam Zheng Committed by Paolo Bonzini
Browse files

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: default avatarDavid Gibson <dgibson@redhat.com>
Signed-off-by: default avatarFam Zheng <famz@redhat.com>

Message-Id: <20180327164141.19075-1-famz@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent db1b5f13
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -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;