From nobody Mon Feb 9 04:56:37 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503324862769336.5702273476239; Mon, 21 Aug 2017 07:14:22 -0700 (PDT) Received: from localhost ([::1]:48519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djnTB-00061k-Ea for importer@patchew.org; Mon, 21 Aug 2017 10:14:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djnPS-0002ub-Tx for qemu-devel@nongnu.org; Mon, 21 Aug 2017 10:10:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djnPN-0001Yv-AO for qemu-devel@nongnu.org; Mon, 21 Aug 2017 10:10:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47394) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1djnPN-0001YZ-48 for qemu-devel@nongnu.org; Mon, 21 Aug 2017 10:10:25 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 37F0D13A9F for ; Mon, 21 Aug 2017 14:10:24 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-62.pek2.redhat.com [10.72.12.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7817D6CDA7; Mon, 21 Aug 2017 14:10:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 37F0D13A9F Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=famz@redhat.com From: Fam Zheng To: qemu-devel@nongnu.org Date: Mon, 21 Aug 2017 22:10:06 +0800 Message-Id: <20170821141008.19383-3-famz@redhat.com> In-Reply-To: <20170821141008.19383-1-famz@redhat.com> References: <20170821141008.19383-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 21 Aug 2017 14:10:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 2/4] scsi: Improve scsi_sense_to_errno 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Tweak the errno mapping to return more accurate/appropriate values. Signed-off-by: Fam Zheng --- util/scsi.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/util/scsi.c b/util/scsi.c index a6710799fc..472eb5bea5 100644 --- a/util/scsi.c +++ b/util/scsi.c @@ -18,13 +18,16 @@ int scsi_sense_to_errno(int key, int asc, int ascq) { switch (key) { - case 0x02: /* NOT READY */ - return EBUSY; - case 0x07: /* DATA PROTECTION */ - return EACCES; + case 0x00: /* NO SENSE */ + case 0x01: /* RECOVERED ERROR */ + case 0x06: /* UNIT ATTENTION */ + /* These sense keys are not errors */ + return 0; case 0x0b: /* COMMAND ABORTED */ return ECANCELED; + case 0x02: /* NOT READY */ case 0x05: /* ILLEGAL REQUEST */ + case 0x07: /* DATA PROTECTION */ /* Parse ASCQ */ break; default: @@ -37,6 +40,7 @@ int scsi_sense_to_errno(int key, int asc, int ascq) case 0x2600: /* INVALID FIELD IN PARAMETER LIST */ return EINVAL; case 0x2100: /* LBA OUT OF RANGE */ + case 0x2707: /* SPACE ALLOC FAILED */ return ENOSPC; case 0x2500: /* LOGICAL UNIT NOT SUPPORTED */ return ENOTSUP; @@ -46,6 +50,10 @@ int scsi_sense_to_errno(int key, int asc, int ascq) return ENOMEDIUM; case 0x2700: /* WRITE PROTECTED */ return EACCES; + case 0x0401: /* NOT READY, IN PROGRESS OF BECOMING READY */ + return EAGAIN; + case 0x0402: /* NOT READY, INITIALIZING COMMAND REQUIRED */ + return ENOTCONN; default: return EIO; } --=20 2.13.5