From nobody Thu Nov 6 12:14:09 2025 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; 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 154083475486818.853388171742154; Mon, 29 Oct 2018 10:39:14 -0700 (PDT) Received: from localhost ([::1]:47635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHBVN-0006sr-R3 for importer@patchew.org; Mon, 29 Oct 2018 13:39:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHBRJ-0002sk-0O for qemu-devel@nongnu.org; Mon, 29 Oct 2018 13:35:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHBRH-0001NK-3h for qemu-devel@nongnu.org; Mon, 29 Oct 2018 13:34:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40958) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHBRE-0001Fp-Vs for qemu-devel@nongnu.org; Mon, 29 Oct 2018 13:34:53 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0B92C29CCC3; Mon, 29 Oct 2018 17:34:48 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-24.ams2.redhat.com [10.36.112.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84F2710D8980; Mon, 29 Oct 2018 17:34:47 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 29 Oct 2018 18:34:37 +0100 Message-Id: <20181029173437.32559-5-pbonzini@redhat.com> In-Reply-To: <20181029173437.32559-1-pbonzini@redhat.com> References: <20181029173437.32559-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 29 Oct 2018 17:34:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 4/4] scsi-generic: do not do VPD emulation for sense other than ILLEGAL_REQUEST 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: Daniel Henrique Barboza , mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Pass other sense, such as UNIT_ATTENTION or BUSY, directly to the guest. Reported-by: Max Reitz Signed-off-by: Paolo Bonzini Reviewed-by: Max Reitz --- hw/scsi/scsi-generic.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index 8fc74ef0bd..b8fa0a0f7e 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -246,7 +246,6 @@ static void scsi_read_complete(void * opaque, int ret) { SCSIGenericReq *r =3D (SCSIGenericReq *)opaque; SCSIDevice *s =3D r->req.dev; - SCSISense sense; int len; =20 assert(r->req.aiocb !=3D NULL); @@ -269,12 +268,15 @@ static void scsi_read_complete(void * opaque, int ret) * resulted in sense error but would need emulation. * In this case, emulate a valid VPD response. */ - if (s->needs_vpd_bl_emulation) { + if (ret =3D=3D 0 && + (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) && + scsi_parse_sense_buf(r->req.sense, r->io_header.sb_len_wr).key =3D= =3D ILLEGAL_REQUEST && + s->needs_vpd_bl_emulation) { int is_vpd_bl =3D r->req.cmd.buf[0] =3D=3D INQUIRY && r->req.cmd.buf[1] & 0x01 && r->req.cmd.buf[2] =3D=3D 0xb0; =20 - if (is_vpd_bl && sg_io_sense_from_errno(-ret, &r->io_header, &sens= e)) { + if (is_vpd_bl) { len =3D scsi_generic_emulate_block_limits(r, s); /* * No need to let scsi_read_complete go on and handle an --=20 2.17.1