From patchwork Fri Aug 18 14:15:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 9909179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE334602C8 for ; Fri, 18 Aug 2017 14:19:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDAD728539 for ; Fri, 18 Aug 2017 14:19:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E25192859A; Fri, 18 Aug 2017 14:19:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7EDAE28539 for ; Fri, 18 Aug 2017 14:19:29 +0000 (UTC) Received: from localhost ([::1]:57062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dii7U-0000Ad-LO for patchwork-qemu-devel@patchwork.kernel.org; Fri, 18 Aug 2017 10:19:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dii3Z-0006A2-1B for qemu-devel@nongnu.org; Fri, 18 Aug 2017 10:15:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dii3Y-0005sz-4S for qemu-devel@nongnu.org; Fri, 18 Aug 2017 10:15:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40576) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dii3X-0005qK-UN for qemu-devel@nongnu.org; Fri, 18 Aug 2017 10:15:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB50C7EA8D for ; Fri, 18 Aug 2017 14:15:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EB50C7EA8D Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=famz@redhat.com Received: from lemon.redhat.com (ovpn-12-120.pek2.redhat.com [10.72.12.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id B12AB6364D; Fri, 18 Aug 2017 14:15:19 +0000 (UTC) From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 18 Aug 2017 22:15:11 +0800 Message-Id: <20170818141512.15205-3-famz@redhat.com> In-Reply-To: <20170818141512.15205-1-famz@redhat.com> References: <20170818141512.15205-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 18 Aug 2017 14:15:23 +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 v3 2/3] scsi: Enhance 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Two changes: 1) Look at asc/ascq for NOT_READY and DATA_PROTECT; 2) Translate SPACE_ALLOC_FAILED as ENOSPC; Signed-off-by: Fam Zheng --- util/scsi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/util/scsi.c b/util/scsi.c index 92ca436cd0..d42ce33449 100644 --- a/util/scsi.c +++ b/util/scsi.c @@ -18,13 +18,11 @@ int scsi_sense_to_errno(int key, int asc, int ascq) { switch (key) { - case 0x02: /* SCSI_SENSE_NOT_READY */ - return EBUSY; - case 0x07: /* SCSI_SENSE_DATA_PROTECTION */ - return EACCES; case 0x0b: /* SCSI_SENSE_COMMAND_ABORTED */ return ECANCELED; + case 0x02: /* SCSI_SENSE_NOT_READY */ case 0x05: /* SCSI_SENSE_ILLEGAL_REQUEST */ + case 0x07: /* SCSI_SENSE_DATA_PROTECTION */ /* Parse ASCQ */ break; default: @@ -37,6 +35,7 @@ int scsi_sense_to_errno(int key, int asc, int ascq) case 0x2600: /* SCSI_SENSE_ASCQ_INVALID_FIELD_IN_PARAMETER_LIST */ return EINVAL; case 0x2100: /* SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE */ + case 0x2707: /* SCSI_SENSE_ASCQ_SPACE_ALLOC_FAILED */ return ENOSPC; case 0x2500: /* SCSI_SENSE_ASCQ_LOGICAL_UNIT_NOT_SUPPORTED */ return ENOTSUP;