From nobody Mon Feb 9 23:02:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1614327277; cv=none; d=zohomail.com; s=zohoarc; b=FACLXcZkdFQtnG6G1uRtUNhyTYJBoDC83aA/dPwxmtLoA+3Fy0dTGFoH4zoPb1q6Z5VGFD5IFPIVb35sEeaq0bg2rp0waiTLXhyCGgE5bcmCcqMqyCl7A9gVz+OY9FCWy3S1iU9lJ86jvS1sRITK6DunF/29Kt2rU+PNxdm3PCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614327277; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ycz7tMt4XNpb7H0VgGp30K9fstHZJN03neY0qoiIQu0=; b=kaRcckH7H/Qiy1Rnb0A8UPlWEKRqWlrWyK5z6nR2cc9Gvya/KtJT9EzslMZlU0P0cvDrRV8g/eooUKhYlR52lW8Iu3p9NfqocsgUVN+/+yj8S7tHzLD1ut5JYPM2YulTGlITdVNmJpeh4WkvJWr4ako6Trjx1JKyR0vpZpDEyhE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614327277344613.1691464561734; Fri, 26 Feb 2021 00:14:37 -0800 (PST) Received: from localhost ([::1]:50460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lFYGh-0002Sk-7d for importer@patchew.org; Fri, 26 Feb 2021 03:14:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lFY85-0001nT-9W for qemu-devel@nongnu.org; Fri, 26 Feb 2021 03:05:43 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:54857) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lFY81-00047W-1T for qemu-devel@nongnu.org; Fri, 26 Feb 2021 03:05:39 -0500 Received: by mail-wm1-x331.google.com with SMTP id u187so4748368wmg.4 for ; Fri, 26 Feb 2021 00:05:36 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n66sm10700830wmn.25.2021.02.26.00.05.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Feb 2021 00:05:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ycz7tMt4XNpb7H0VgGp30K9fstHZJN03neY0qoiIQu0=; b=EpzvkFknQfEv4DPn+lmkVVsuscXs0RhCx0aLXB+w9UP5J7YyrdAjEwT1aWghYXYPGe grlOxXmKBKhKs1NkoSt9j3b11epk0T8unzb4ns+80KDEB5Wn8fWrTpteQ3dlGgCqIFts kWlSQI1PM3ygMQDXtKXjFgZUhmbZU/kEWRtGNGZP9Qetzv9bACqJ9OvilkIhkp1H/Ki5 BIh5CKq0qq+dLR9nNpRbXrH+xtIrXBjVFtUqVSAViBK3kIR7+Kti79MkJlHWUPaSrdV8 jF3FiSLgpG9zDxEsnGKMYtQvPz3JVUwHofm/f29TCC0LDFl5H1eo/gD1/62wwMOn+0Pq 3oRw== 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:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Ycz7tMt4XNpb7H0VgGp30K9fstHZJN03neY0qoiIQu0=; b=V8OMDsN6dumdWqbb/MSBLEk2vgXi1ZPZQJFbyuyDlLcx9HP5gfvHB5Bylt+gyIS51F IgFulzLQxm+tnXtm1NwjbRf2oRoMgS/nqcHJA6f+uOPN39F5dSQ04nbgQwBxg2pVBVPn 2E/qhrpvlTOJUz6gV0jaSpAHdJW/f30kDV47JUIzHKi7AgIJKKf3pBU0YDCz2U4k2zXr Ei3XpFby6AcYCII6OqPVei2M53GM81RGRANEgAd/kRIBOodHvFyx8MU837TKBVkSYZWh xaHubPW1749FbvGUJ5v5iLka4IT05LGBoo2dGafWVgtCU+cf/35hiZFuSDSrLvwgtUE5 QNHQ== X-Gm-Message-State: AOAM533VrR/GOB6ofNJxHJYPFJ/TTT5FW8xyInZSO00cPeNA+DAr6I3y FbDVV5Z1riICSWL/hHQ5NBZVTsSK6TA= X-Google-Smtp-Source: ABdhPJzKQaFJD/90C9sL+u9QbRQ/BJBop87yx0fBYvmRa6k88XQZwA2QxPXgnTmW4T6HvimAaK4Fkg== X-Received: by 2002:a1c:7fd8:: with SMTP id a207mr1523374wmd.40.1614326735610; Fri, 26 Feb 2021 00:05:35 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 12/29] scsi-disk: pass guest recoverable errors through even for rerror=stop Date: Fri, 26 Feb 2021 09:05:09 +0100 Message-Id: <20210226080526.651705-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210226080526.651705-1-pbonzini@redhat.com> References: <20210226080526.651705-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::331; envelope-from=paolo.bonzini@gmail.com; helo=mail-wm1-x331.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Right now, recoverable sense values are only passed directly to the guest only for rerror=3Dreport. However, when rerror/werror are 'stop' we still don't want the host to be involved on every UNIT ATTENTION (especially considered that the QMP event will not have enough information to act on the report). Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-disk.c | 51 +++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 548a5297fa..a5a58d7db3 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -212,39 +212,44 @@ static bool scsi_handle_rw_error(SCSIDiskReq *r, int = ret, bool acct_failed) } } =20 - action =3D blk_get_error_action(s->qdev.conf.blk, is_read, error); - if (action =3D=3D BLOCK_ERROR_ACTION_REPORT) { + /* + * Check whether the error has to be handled by the guest or should + * rather follow the rerror=3D/werror=3D settings. Guest-handled erro= rs + * are usually retried immediately, so do not post them to QMP and + * do not account them as failed I/O. + */ + if (req_has_sense && + scsi_sense_buf_is_guest_recoverable(r->req.sense, sizeof(r->req.se= nse))) { + action =3D BLOCK_ERROR_ACTION_REPORT; + acct_failed =3D false; + } else { + action =3D blk_get_error_action(s->qdev.conf.blk, is_read, error); + blk_error_action(s->qdev.conf.blk, action, is_read, error); + } + + switch (action) { + case BLOCK_ERROR_ACTION_REPORT: if (acct_failed) { block_acct_failed(blk_get_stats(s->qdev.conf.blk), &r->acct); } if (req_has_sense) { - /* A passthrough command has run and has produced sense data; = check - * whether the error has to be handled by the guest or should = rather - * pause the host. - */ - if (scsi_sense_buf_is_guest_recoverable(r->req.sense, sizeof(r= ->req.sense))) { - /* These errors are handled by guest. */ - sdc->update_sense(&r->req); - scsi_req_complete(&r->req, status); - return true; - } - } else { - if (status =3D=3D CHECK_CONDITION) { - scsi_req_build_sense(&r->req, sense); - } - scsi_req_complete(&r->req, status); + sdc->update_sense(&r->req); + } else if (status =3D=3D CHECK_CONDITION) { + scsi_req_build_sense(&r->req, sense); } - } + scsi_req_complete(&r->req, status); + return true; =20 - blk_error_action(s->qdev.conf.blk, action, is_read, error); - if (action =3D=3D BLOCK_ERROR_ACTION_IGNORE) { + case BLOCK_ERROR_ACTION_IGNORE: return false; - } =20 - if (action =3D=3D BLOCK_ERROR_ACTION_STOP) { + case BLOCK_ERROR_ACTION_STOP: scsi_req_retry(&r->req); + return true; + + default: + g_assert_not_reached(); } - return true; } =20 static bool scsi_disk_req_check_error(SCSIDiskReq *r, int ret, bool acct_f= ailed) --=20 2.29.2