From: Roman Kagan Date: Thu, 8 Jun 2017 09:58:07 +0000 (+0300) Subject: blockcmd: start REPORT_LUNS with the smallest buffer X-Git-Tag: rel-1.11.0~32 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=6345621ded7fe999084501ba9382913b079acc9c;p=seabios.git blockcmd: start REPORT_LUNS with the smallest buffer A number of emulated SCSI devices in QEMU incorrectly return an error to REPORT_LUNS command when the size of the data returned is smaller than the allocation length passed in. To work it around, start with the smallest allocation length possible: for 1 entry. This is a slight pessimization because it would require another REPORT_LUNS iteration if the target has more than a single LUN, but this appears to have negligible impact on boot times, and makes REPORT_LUNS enumeration work for more QEMU devices (lsi53c895a, mptsas1068). Reported-by: Maciej Józefczyk Signed-off-by: Roman Kagan --- diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index 324188d..98c06ce 100644 --- a/src/hw/blockcmd.c +++ b/src/hw/blockcmd.c @@ -215,7 +215,9 @@ static u64 scsilun2u64(struct scsi_lun *scsi_lun) int scsi_rep_luns_scan(struct drive_s *tmp_drive, scsi_add_lun add_lun) { int ret = -1; - u32 maxluns = 511; + /* start with the smallest possible buffer, otherwise some devices in QEMU + * may (incorrectly) error out on returning less data than fits in it */ + u32 maxluns = 1; u32 nluns, i; struct cdb_report_luns cdb = { .command = CDB_CMD_REPORT_LUNS,