From nobody Fri May 3 12:31:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522945556079674.7392307431614; Thu, 5 Apr 2018 09:25:56 -0700 (PDT) Received: from localhost ([::1]:40377 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f47hz-0003lx-94 for importer@patchew.org; Thu, 05 Apr 2018 12:25:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f47g3-0002Sy-Kw for qemu-devel@nongnu.org; Thu, 05 Apr 2018 12:23:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f47g1-0002Kv-I6 for qemu-devel@nongnu.org; Thu, 05 Apr 2018 12:23:55 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:36854) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f47g1-0002Ka-7p for qemu-devel@nongnu.org; Thu, 05 Apr 2018 12:23:53 -0400 Received: by mail-wm0-x241.google.com with SMTP id x82so8797680wmg.1 for ; Thu, 05 Apr 2018 09:23:53 -0700 (PDT) Received: from donizetti.lan (94-36-194-48.adsl-ull.clienti.tiscali.it. [94.36.194.48]) by smtp.gmail.com with ESMTPSA id m190sm9628541wmb.6.2018.04.05.09.23.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Apr 2018 09:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=W7RhW2PnFeMy4Miz+kj9Hb48tP/1+btO7UA6fdUIvQg=; b=TiLxxPmGlGGr18a6RXL7cTfolK6lM8qS72FxkYRrLn6rmA/tOJzABXf2lI87FqI78f uD2d4A++rTiaRMqVJ9hZ1r9NUo7slrg5dh+XMU2NSvn0ZCHNV3UAjifWqsvFiH7sZzlZ ckcgd2mWhqCEoklEM6HHTas8Ybab8reoh1qIBxCXEwy+rtaapTV16tzi2qi2V8f3/1qs g1NI23QrKDCbg8rRxKME+tzAspk2HF4sCn32r7s2ymuE7yfLaDU8bujruwnnxQlIB0QO FmS5gFXz+Quy8ToCDslubnX6odsRkNpaHXuXhhTLn8wPBFGkRTTk1kjboKTxGPVz7Vld Bkjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=W7RhW2PnFeMy4Miz+kj9Hb48tP/1+btO7UA6fdUIvQg=; b=GMn69IG+wnBT6z3Z8MWLa4tf8kk99pj+87ZIxw95MvbnqqK7vlOCjjSbzyqpcEjB+6 EpREO6Kh/EjXNTSRBYB5Wb8hQzKq0C4l7RzZ4/PlNccu3eTJeCQOwuDv20FknI0mBNl5 P/qrOCU4ILtHH3TXUy2H/Z2PFuHP54vBeG1ByZCcOm8oqvMrleBh5T79dot2qbGtLQ3Q WwMa/v3/GadYxAXqZiZJ+G4NOLtS3iiM6eqY73HIYU8g6Svt9yfbeQJ5virbt6qWQrOb krDsyA1EtzIYeHaT/Lk3VkfK4XJ03ByzANceF6SXhhkKWmIXQGAtyqBlP6rCwp3aKoGX IYMA== X-Gm-Message-State: ALQs6tCD4nkaC6jlJcVPR45r3a+hPnervl/jNCkZQ5QD3ijPXRSj/KQh ka5eJrBY7DvU2yVt7q8I/xJ/F/2O X-Google-Smtp-Source: AIpwx49vafw7HX/zyaNpJMTg6Gah4esk/GIclP26YXGSL8CFch+nkXk9vaz+Yt5YDcd+CDiHFW14kQ== X-Received: by 10.28.230.156 with SMTP id e28mr6534670wmi.28.1522945431835; Thu, 05 Apr 2018 09:23:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 18:23:46 +0200 Message-Id: <20180405162347.5623-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180405162347.5623-1-pbonzini@redhat.com> References: <20180405162347.5623-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH 1/2] scsi-disk: allow customizing the SCSI version X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: danielhb@linux.vnet.ibm.com, famz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We would like to have different behavior for passthrough devices depending on the SCSI version they expose. To prepare for that, allow the user of emulated devices to specify the desired SCSI level, and adjust the emulation according to the property value. The next patch will set the level for scsi-block and scsi-generic devices. Based on a patch by Daniel Henrique Barboza . Signed-off-by: Paolo Bonzini Reviewed-by: Daniel Henrique Barboza Tested-by: Daniel Henrique Barboza --- hw/scsi/scsi-disk.c | 29 ++++++++++++++++++++++++----- hw/scsi/scsi-generic.c | 1 + include/hw/scsi/scsi.h | 2 ++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index f8ed8cf2b4..9400b97387 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -825,7 +825,7 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, = uint8_t *outbuf) * block characteristics VPD page by default. Not all of SPC-3 * is actually implemented, but we're good enough. */ - outbuf[2] =3D 5; + outbuf[2] =3D s->qdev.default_scsi_version; outbuf[3] =3D 2 | 0x10; /* Format 2, HiSup */ =20 if (buflen > 36) { @@ -2193,7 +2193,11 @@ static int32_t scsi_disk_dma_command(SCSIRequest *re= q, uint8_t *buf) case READ_12: case READ_16: DPRINTF("Read (sector %" PRId64 ", count %u)\n", r->req.cmd.lba, l= en); - if (r->req.cmd.buf[1] & 0xe0) { + /* Protection information is not supported. For SCSI versions 2 a= nd + * older (as determined by snooping the guest's INQUIRY commands), + * there is no RD/WR/VRPROTECT, so skip this check in these versio= ns. + */ + if (s->qdev.scsi_version > 2 && (r->req.cmd.buf[1] & 0xe0)) { goto illegal_request; } if (!check_lba_range(s, r->req.cmd.lba, len)) { @@ -2224,7 +2228,7 @@ static int32_t scsi_disk_dma_command(SCSIRequest *req= , uint8_t *buf) * As far as DMA is concerned, we can treat it the same as a write; * scsi_block_do_sgio will send VERIFY commands. */ - if (r->req.cmd.buf[1] & 0xe0) { + if (s->qdev.scsi_version > 2 && (r->req.cmd.buf[1] & 0xe0)) { goto illegal_request; } if (!check_lba_range(s, r->req.cmd.lba, len)) { @@ -2270,6 +2274,8 @@ static void scsi_disk_reset(DeviceState *dev) /* reset tray statuses */ s->tray_locked =3D 0; s->tray_open =3D 0; + + s->qdev.scsi_version =3D s->qdev.default_scsi_version; } =20 static void scsi_disk_resize_cb(void *opaque) @@ -2814,6 +2820,8 @@ static bool scsi_block_is_passthrough(SCSIDiskState *= s, uint8_t *buf) static int32_t scsi_block_dma_command(SCSIRequest *req, uint8_t *buf) { SCSIBlockReq *r =3D (SCSIBlockReq *)req; + SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, req->dev); + r->cmd =3D req->cmd.buf[0]; switch (r->cmd >> 5) { case 0: @@ -2839,8 +2847,11 @@ static int32_t scsi_block_dma_command(SCSIRequest *r= eq, uint8_t *buf) abort(); } =20 - if (r->cdb1 & 0xe0) { - /* Protection information is not supported. */ + /* Protection information is not supported. For SCSI versions 2 and + * older (as determined by snooping the guest's INQUIRY commands), + * there is no RD/WR/VRPROTECT, so skip this check in these versions. + */ + if (s->qdev.scsi_version > 2 && (req->cmd.buf[1] & 0xe0)) { scsi_check_condition(&r->req, SENSE_CODE(INVALID_FIELD)); return 0; } @@ -2952,6 +2963,8 @@ static Property scsi_hd_properties[] =3D { DEFINE_PROP_UINT64("max_io_size", SCSIDiskState, max_io_size, DEFAULT_MAX_IO_SIZE), DEFINE_PROP_UINT16("rotation_rate", SCSIDiskState, rotation_rate, 0), + DEFINE_PROP_INT32("scsi_version", SCSIDiskState, qdev.default_scsi_ver= sion, + 5), DEFINE_BLOCK_CHS_PROPERTIES(SCSIDiskState, qdev.conf), DEFINE_PROP_END_OF_LIST(), }; @@ -2997,6 +3010,8 @@ static Property scsi_cd_properties[] =3D { DEFINE_PROP_UINT16("port_index", SCSIDiskState, port_index, 0), DEFINE_PROP_UINT64("max_io_size", SCSIDiskState, max_io_size, DEFAULT_MAX_IO_SIZE), + DEFINE_PROP_INT32("scsi_version", SCSIDiskState, qdev.default_scsi_ver= sion, + 5), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -3025,6 +3040,8 @@ static Property scsi_block_properties[] =3D { DEFINE_PROP_DRIVE("drive", SCSIDiskState, qdev.conf.blk), DEFINE_PROP_BOOL("share-rw", SCSIDiskState, qdev.conf.share_rw, false), DEFINE_PROP_UINT16("rotation_rate", SCSIDiskState, rotation_rate, 0), + DEFINE_PROP_INT32("scsi_version", SCSIDiskState, qdev.default_scsi_ver= sion, + 5), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -3065,6 +3082,8 @@ static Property scsi_disk_properties[] =3D { DEFAULT_MAX_UNMAP_SIZE), DEFINE_PROP_UINT64("max_io_size", SCSIDiskState, max_io_size, DEFAULT_MAX_IO_SIZE), + DEFINE_PROP_INT32("scsi_version", SCSIDiskState, qdev.default_scsi_ver= sion, + 5), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index 4753f8738f..1870085762 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -474,6 +474,7 @@ static void scsi_generic_reset(DeviceState *dev) { SCSIDevice *s =3D SCSI_DEVICE(dev); =20 + s->scsi_version =3D s->default_scsi_version; scsi_device_purge_requests(s, SENSE_CODE(RESET)); } =20 diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index 7ecaddac9d..e35137ea78 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -85,6 +85,8 @@ struct SCSIDevice uint64_t max_lba; uint64_t wwn; uint64_t port_wwn; + int scsi_version; + int default_scsi_version; }; =20 extern const VMStateDescription vmstate_scsi_device; --=20 2.16.2 From nobody Fri May 3 12:31:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522945549674151.3131902294931; Thu, 5 Apr 2018 09:25:49 -0700 (PDT) Received: from localhost ([::1]:40372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f47hq-0003e4-Rn for importer@patchew.org; Thu, 05 Apr 2018 12:25:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f47g3-0002TB-Uh for qemu-devel@nongnu.org; Thu, 05 Apr 2018 12:23:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f47g2-0002LQ-NE for qemu-devel@nongnu.org; Thu, 05 Apr 2018 12:23:55 -0400 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:41709) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f47g2-0002L3-D0 for qemu-devel@nongnu.org; Thu, 05 Apr 2018 12:23:54 -0400 Received: by mail-wr0-x234.google.com with SMTP id s12so18800516wrc.8 for ; Thu, 05 Apr 2018 09:23:54 -0700 (PDT) Received: from donizetti.lan (94-36-194-48.adsl-ull.clienti.tiscali.it. [94.36.194.48]) by smtp.gmail.com with ESMTPSA id m190sm9628541wmb.6.2018.04.05.09.23.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Apr 2018 09:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=9pNs24E3gNIGlSgq8NgWpUBSiRC0sa51trb1r00xXk8=; b=uR2keJtsspRjf6xw6LWylpNwbP2IkLa08w23jAMe4LY+SI3Ljn53CRZmv2MpZybVSA w/XsA1/HtXATflkHZW2aWAMuqW3sO4nqwYYlsEdn2zs9yFbCtJFQXDkLNIC60MuXrUqS DcCWE3fkuOAyDaRUsE/2kMyZX6eYInt5zOlf4ZcsN4ZdSeUuwcebg84pEuv5GC7Igq16 0Doil+tvH+ZYZlnbADc0IbQTX4khSl18u45ou/9Olu9TRlU9Z6y5DUerWk5XUdM8/wPj XaXr3VHYfmu8h/QUArlaVrYIYsKVImW45mRJ/jre40OkhunQAEqnxxnA8jC2U5wWPP4u nsCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=9pNs24E3gNIGlSgq8NgWpUBSiRC0sa51trb1r00xXk8=; b=uUisNR4og8FnkXDRJt/iPzscmZSp4UwpoQZlC3JA0mVyrGofnnKsXjOWL8iqeZuhnT i/3RmKjnPiRa151gjNd8zTFHgYW+goDFgCE94Od3o9Pc8RnYgKhAI+dHjPmgUBVrm20t 3FwmCDZ2jH2mymix8mivcwgiKxHWum/WQWUr1i8GsTD5PnlftvWkbVqhF8Wrc0V9QZVT +iVZqwErLCPemTJQKrz0rgkM8wmrrJgWjfrPftmgufh8SQblGaEOcrPjHiKeKdiLOfV/ LQUlRNmISA8OUsZC3/tMUQnDeufPxUMdB0I2AD/1Is7sX15U0uKLwhbAiQqdJJ4uDgXi 273w== X-Gm-Message-State: AElRT7GtmilbNrL0o9FnfOboEq6UImiUM+J2ldOXeqOi2WmYD1ZuHQg7 rTKsfGiwOZFmzxplpPLEtpYXiGaE X-Google-Smtp-Source: AIpwx4+ZbgqPGzZRzy+tg4NEh4chEnILWdOmrJxjMcEW/thbkllDuDMKPhhwtRSbz0mgGCWdGEXlTA== X-Received: by 10.223.128.98 with SMTP id 89mr16432039wrk.141.1522945432978; Thu, 05 Apr 2018 09:23:52 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 18:23:47 +0200 Message-Id: <20180405162347.5623-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180405162347.5623-1-pbonzini@redhat.com> References: <20180405162347.5623-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::234 Subject: [Qemu-devel] [PATCH 2/2] hw/scsi: support SCSI-2 passthrough without PI X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: danielhb@linux.vnet.ibm.com, famz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza QEMU SCSI code makes assumptions about how the PROTECT and BYTCHK works in the protocol, denying support for PI (Protection Information) in case the guest OS requests it. However, in SCSI versions 2 and older, there is no PI concept in the protocol. This means that when dealing with such devices: - there is no PROTECT bit in byte 5 of the standard INQUIRY response. The whole byte is marked as "Reserved"; - there is no RDPROTECT in byte 2 of READ. We have 'Logical Unit Number' in this field instead; - there is no VRPROTECT in byte 2 of VERIFY. We have 'Logical Unit Number' in this field instead. This also means that the BYTCHK bit in this case is not related to PI. Since QEMU does not consider these changes, a SCSI passthrough using a SCSI-2 device will not work. It will mistake these fields with PI information and return Illegal Request SCSI SENSE thinking that the driver is asking for PI support. This patch fixes it by adding a new attribute called 'scsi_version' that is read from the standard INQUIRY response of passthrough devices. This allows for a version verification before applying conditions related to PI that doesn't apply for older versions. Reported-by: Dac Nguyen Signed-off-by: Daniel Henrique Barboza Message-Id: <20180327211451.14647-1-danielhb@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-disk.c | 2 +- hw/scsi/scsi-generic.c | 47 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 9400b97387..ded23d36ca 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -3041,7 +3041,7 @@ static Property scsi_block_properties[] =3D { DEFINE_PROP_BOOL("share-rw", SCSIDiskState, qdev.conf.share_rw, false), DEFINE_PROP_UINT16("rotation_rate", SCSIDiskState, rotation_rate, 0), DEFINE_PROP_INT32("scsi_version", SCSIDiskState, qdev.default_scsi_ver= sion, - 5), + -1), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index 1870085762..381f04e339 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -194,17 +194,40 @@ static void scsi_read_complete(void * opaque, int ret) r->buf[3] |=3D 0x80; } } - if (s->type =3D=3D TYPE_DISK && - r->req.cmd.buf[0] =3D=3D INQUIRY && - r->req.cmd.buf[2] =3D=3D 0xb0) { - uint32_t max_transfer =3D - blk_get_max_transfer(s->conf.blk) / s->blocksize; - - assert(max_transfer); - stl_be_p(&r->buf[8], max_transfer); - /* Also take care of the opt xfer len. */ - stl_be_p(&r->buf[12], - MIN_NON_ZERO(max_transfer, ldl_be_p(&r->buf[12]))); + if (r->req.cmd.buf[0] =3D=3D INQUIRY) { + /* + * EVPD set to zero returns the standard INQUIRY data. + * + * Check if scsi_version is unset (-1) to avoid re-defining it + * each time an INQUIRY with standard data is received. + * scsi_version is initialized with -1 in scsi_generic_reset + * and scsi_disk_reset, making sure that we'll set the + * scsi_version after a reset. If the version field of the + * INQUIRY response somehow changes after a guest reboot, + * we'll be able to keep track of it. + * + * On SCSI-2 and older, first 3 bits of byte 2 is the + * ANSI-approved version, while on later versions the + * whole byte 2 contains the version. Check if we're dealing + * with a newer version and, in that case, assign the + * whole byte. + */ + if (s->scsi_version =3D=3D -1 && !(r->req.cmd.buf[1] & 0x01)) { + s->scsi_version =3D r->buf[2] & 0x07; + if (s->scsi_version > 2) { + s->scsi_version =3D r->buf[2]; + } + } + if (s->type =3D=3D TYPE_DISK && r->req.cmd.buf[2] =3D=3D 0xb0) { + uint32_t max_transfer =3D + blk_get_max_transfer(s->conf.blk) / s->blocksize; + + assert(max_transfer); + stl_be_p(&r->buf[8], max_transfer); + /* Also take care of the opt xfer len. */ + stl_be_p(&r->buf[12], + MIN_NON_ZERO(max_transfer, ldl_be_p(&r->buf[12]))); + } } scsi_req_data(&r->req, len); scsi_req_unref(&r->req); @@ -550,6 +573,8 @@ static void scsi_generic_realize(SCSIDevice *s, Error *= *errp) =20 DPRINTF("block size %d\n", s->blocksize); =20 + /* Only used by scsi-block, but initialize it nevertheless to be clean= . */ + s->default_scsi_version =3D -1; scsi_generic_read_device_identification(s); } =20 --=20 2.16.2