From nobody Sun Feb 8 14:22:54 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1605553339; cv=none; d=zohomail.com; s=zohoarc; b=FJM4iVyLbetmbIFWgXEfcdVSBDWwL/rRy3ZIrwtTYt0iMedA+3RSCY38ClVIqM9fNmqQGLYJyXk3KArhcRnNzEeVf858xVaHshgmpRgpFTEZxGfNRqYrXUU6gQQx7Tf/3wja6fMF/j9G32KZpC4IOwhK0zslXZTxc89wZN28Hu4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605553339; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=KQAXpMu4LcMBChR8viVcqttblb551DyD6x3L8O5VjZs=; b=SIL457GODnmUI7dnGyliZKNzM4DOWQkAG9YaiKj0VUBZ6iQ2MPlE/MtTQLtfFqVqWwno4/O7xImhMyJSYnEq99jxCnA58f78twSmHsTZq4YRVp7UHxpHdfXu0zbxk1U/sAur4IlscTTCppDciOx/PAhyuAsNRn8cEoTavQvC3+E= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1605553339925829.1673466397348; Mon, 16 Nov 2020 11:02:19 -0800 (PST) Received: from localhost ([::1]:47414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kejla-0005Qc-IJ for importer@patchew.org; Mon, 16 Nov 2020 14:02:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kejR2-0003yL-Cp for qemu-devel@nongnu.org; Mon, 16 Nov 2020 13:41:04 -0500 Received: from mx2.suse.de ([195.135.220.15]:45330) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kejQo-0000lF-Q5 for qemu-devel@nongnu.org; Mon, 16 Nov 2020 13:41:03 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 436F6B011; Mon, 16 Nov 2020 18:40:49 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Hannes Reinecke To: Paolo Bonzini Subject: [PATCH 3/7] scsi-disk: convert more errno values back to SCSI statuses Date: Mon, 16 Nov 2020 19:40:37 +0100 Message-Id: <20201116184041.60465-4-hare@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20201116184041.60465-1-hare@suse.de> References: <20201116184041.60465-1-hare@suse.de> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.15; envelope-from=hare@suse.de; helo=mx2.suse.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/16 12:53:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x (no timestamps) [generic] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Hannes Reinecke 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" From: Paolo Bonzini Linux has some OS-specific (and sometimes weird) mappings for various SCSI statuses and sense codes. The most important is probably RESERVATION CONFLICT. Add them so that they can be reported back to the guest kernel. Cc: Hannes Reinecke Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-disk.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 5d6c892f29..797779afd6 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -460,6 +460,25 @@ static bool scsi_handle_rw_error(SCSIDiskReq *r, int e= rror, bool acct_failed) } error =3D scsi_sense_buf_to_errno(r->req.sense, sizeof(r->req.= sense)); break; +#ifdef CONFIG_LINUX + /* These errno mapping are specific to Linux. For more inform= ation: + * - scsi_decide_disposition in drivers/scsi/scsi_error.c + * - scsi_result_to_blk_status in drivers/scsi/scsi_lib.c + * - blk_errors[] in block/blk-core.c + */ + case EBADE: + /* DID_NEXUS_FAILURE -> BLK_STS_NEXUS. */ + scsi_req_complete(&r->req, RESERVATION_CONFLICT); + break; + case ENODATA: + /* DID_MEDIUM_ERROR -> BLK_STS_MEDIUM. */ + scsi_check_condition(r, SENSE_CODE(READ_ERROR)); + break; + case EREMOTEIO: + /* DID_TARGET_FAILURE -> BLK_STS_TARGET. */ + scsi_req_complete(&r->req, HARDWARE_ERROR); + break; +#endif case ENOMEDIUM: scsi_check_condition(r, SENSE_CODE(NO_MEDIUM)); break; --=20 2.16.4