From nobody Thu Oct 22 19:27:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791915597; cv=none; d=zohomail.com; s=zohoarc; b=BP2LG5IWaB9X4QAE0wYyG81kqVIpO9j0i1JvS3dScIs0KlnXYX7y6HyfqO3Oht2Ctq6kEBLPWADgb1xcptpqTbwij46dVJ7PB70vUj8lMdHe8N1VguL9Ct0TlH+SMS9ft/FigVQN75p47i2a65j+XoCKpzrvyWjl9nXf9LW7twg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791915597; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=U8EFpisl4E7965xetZNyNyjvdSnI2AFbeVIm/IiRNTY=; b=kwHS/vAYJ4hF9MzMVjIB/EB+aVmkTRFTGEMpvPwdOgpF0nBzydNr6ru/VbqSka62XkYyKMPHcW7l4V7F69pe/Ud03VJleW/Mg5SGe+AoAdZ15iH+Wvroald7orxfjRVatKx9tcWH6S/3QUHNw5mUt3JF53+p4PvG1CuIaKXs9kg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179191559779049.52678913497266; Tue, 13 Oct 2026 11:19:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGh5E-000716-P9; Tue, 13 Oct 2026 14:18:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4m-0006xI-Bv for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4i-00014L-Hc for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:10 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-6ZmW-E3jNGWE0zZ1DGIXmQ-1; Tue, 13 Oct 2026 18:17:58 +0000 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 161201945CB0; Tue, 13 Oct 2026 18:17:57 +0000 (UTC) Received: from localhost (headnet03.pony-001.prod.iad2.dc.redhat.com [10.2.32.114]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A4116180057E; Tue, 13 Oct 2026 18:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791915487; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U8EFpisl4E7965xetZNyNyjvdSnI2AFbeVIm/IiRNTY=; b=Q6iLR4S3V8BgxGDG1zyAJIUpoASVv13PBpgEGvFzzyRLnrro9pQKm42ueDteH3B2SA68ML bGSrKSZklqjFLzLlMe5K2Bu9LCoKMmQ2czKXFWu25LDNzdtKllpdogMH1Dw3LSVGoapOTr FefEuNppHMoPbaxfMs3gBCj5Be/Xyns= X-MC-Unique: 6ZmW-E3jNGWE0zZ1DGIXmQ-1 X-Mimecast-MFC-AGG-ID: 6ZmW-E3jNGWE0zZ1DGIXmQ_1791915477 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , akalenyu@redhat.com, Kevin Wolf , eblake@redhat.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , Paolo Bonzini , , Hanna Reitz , Benjamin Marzinski , Stefan Hajnoczi Subject: [PATCH v2 1/8] pr-manager-helper: fix sense buffer overflow Date: Tue, 13 Oct 2026 14:17:45 -0400 Message-ID: <20261013181752.1299456-2-stefanha@redhat.com> In-Reply-To: <20261013181752.1299456-1-stefanha@redhat.com> References: <20261013181752.1299456-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791915600221158501 Content-Type: text/plain; charset="utf-8" scsi_build_sense() assumes the sense buffer is SCSI_SENSE_LEN (18) bytes long, so the caller's buffer with an arbitrary size cannot be used. Use our own sense buffer (resp.sense) as an intermediate buffer and honor the caller's sense buffer size (io_hdr->mx_sb_len). This is triggered when scsi-generic.c:scsi_SG_IO() calls blk_ioctl() with an 8-byte sense buffer. There does not appear to be a way for the guest to trigger this buffer overflow directly since SCSIRequest->sense[] is 252 bytes long. Fixes: 9bad2a6b9d0a ("scsi: add persistent reservation manager using qemu-p= r-helper") Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- scsi/pr-manager-helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c index 53432e6d606..26ef3876f0e 100644 --- a/scsi/pr-manager-helper.c +++ b/scsi/pr-manager-helper.c @@ -234,10 +234,11 @@ static int pr_manager_helper_run(PRManager *p, =20 out: if (ret < 0) { - int sense_len =3D scsi_build_sense(io_hdr->sbp, + int sense_len =3D scsi_build_sense(resp.sense, SENSE_CODE(LUN_COMM_FAILURE)); io_hdr->driver_status =3D SG_ERR_DRIVER_SENSE; io_hdr->sb_len_wr =3D MIN(io_hdr->mx_sb_len, sense_len); + memcpy(io_hdr->sbp, resp.sense, io_hdr->sb_len_wr); io_hdr->status =3D CHECK_CONDITION; } qemu_mutex_unlock(&pr_mgr->lock); --=20 2.56.0 From nobody Thu Oct 22 19:27:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791915593; cv=none; d=zohomail.com; s=zohoarc; b=GvhmnaeliR+ZfHWLYUnDBLAyCGckN4hbD7dVNgNeuLB5ytLdqQ/4ZXyX/9BtHQLqkvy7NBTb6gGVDSeiT0pHP6GhEKlrnQ6mnM8dxLBwG5G2ugG/DoNSWm+UH8+MVyBnGs/6Sdq0ytKY0hCC1qnD7OZgaMiWMGqHfVn9sWHiTKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791915593; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QtAgSRTR4WaSqr3J7CKCWgypjzRvaQsrR2BhHoU+HdI=; b=CuThfUR/qVMYrrzgN+xK3pKDQJ4kPlkPUuXa30N+9SeaKZHxtqzC1tAhNOzGIhrn7rlRtezN7oseEs8X/84E9j874xqPXrphIPYM2XdmXh3nmOZ+49iv9g/Tnq98wmqXSRTopOYhy0PsbLnIkUpPsjJzRlWFr6IwC6b1mrylFKk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791915593213368.88832307363805; Tue, 13 Oct 2026 11:19:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGh5p-0007Xo-3v; Tue, 13 Oct 2026 14:19:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4o-0006xY-NT for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4m-00015g-9l for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:14 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-572-pT2UJDLDOo6_ETADrzr20Q-1; Tue, 13 Oct 2026 18:17:59 +0000 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 594121954125; Tue, 13 Oct 2026 18:17:58 +0000 (UTC) Received: from localhost (headnet03.pony-001.prod.iad2.dc.redhat.com [10.2.32.114]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0CDF430001B9; Tue, 13 Oct 2026 18:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791915490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QtAgSRTR4WaSqr3J7CKCWgypjzRvaQsrR2BhHoU+HdI=; b=heirTUedvamGxvqd9pvbl2CIU1fLzmfEYbpvyHKxFbGsN8cRIISa4omySOTjuxxwYTkGk7 WmPLH9DapuqZD4/KbbI8LNyy9u9d3YcpLx+QziFdYofRga8lYzpzaamwq1xqc5hDP3bx17 MOvYkV2qSHEPVwc/os85WQdGhK0K990= X-MC-Unique: pT2UJDLDOo6_ETADrzr20Q-1 X-Mimecast-MFC-AGG-ID: pT2UJDLDOo6_ETADrzr20Q_1791915478 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , akalenyu@redhat.com, Kevin Wolf , eblake@redhat.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , Paolo Bonzini , , Hanna Reitz , Benjamin Marzinski , Stefan Hajnoczi Subject: [PATCH v2 2/8] scsi: increase sense buffer size in scsi_SG_IO() Date: Tue, 13 Oct 2026 14:17:46 -0400 Message-ID: <20261013181752.1299456-3-stefanha@redhat.com> In-Reply-To: <20261013181752.1299456-1-stefanha@redhat.com> References: <20261013181752.1299456-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791915593948158500 Content-Type: text/plain; charset="utf-8" There are different SCSI sense formats. Increase the size so we can get more detailed sense data. Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- hw/scsi/scsi-generic.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index 8999f3b7200..153a5275567 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -923,7 +923,7 @@ int scsi_SG_IO(BlockBackend *blk, int direction, uint8_= t *cmd, uint32_t timeout, Error **errp) { sg_io_hdr_t io_header; - uint8_t sensebuf[8] =3D {}; + uint8_t sensebuf[SCSI_SENSE_LEN] =3D {}; int ret; =20 memset(&io_header, 0, sizeof(io_header)); @@ -947,15 +947,18 @@ int scsi_SG_IO(BlockBackend *blk, int direction, uint= 8_t *cmd, error_setg_errno(errp, -ret, "SG_IO ioctl failed"); } else { g_autofree char *sensebuf_hex =3D - g_strdup_printf("%02x%02x%02x%02x%02x%02x%02x%02x", - sensebuf[0], - sensebuf[1], - sensebuf[2], - sensebuf[3], - sensebuf[4], - sensebuf[5], - sensebuf[6], - sensebuf[7]); + g_strdup_printf("%02x%02x%02x%02x%02x%02x%02x%02x" + "%02x%02x%02x%02x%02x%02x%02x%02x" + "%02x%02x", + sensebuf[0], sensebuf[1], + sensebuf[2], sensebuf[3], + sensebuf[4], sensebuf[5], + sensebuf[6], sensebuf[7], + sensebuf[8], sensebuf[9], + sensebuf[10], sensebuf[11], + sensebuf[12], sensebuf[13], + sensebuf[14], sensebuf[15], + sensebuf[16], sensebuf[17]); =20 error_setg(errp, "SG_IO SCSI command failed with status=3D0x%x= " "driver_status=3D0x%x host_status=3D0x%x sensebuf=3D%s= " --=20 2.56.0 From nobody Thu Oct 22 19:27:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791915542; cv=none; d=zohomail.com; s=zohoarc; b=hB5Qrkf0sfy10hQgYxYx3ojvGzsG8whRwGjoFbYRc6eiw65Bv/Cd9m7xXVWVLVMxV9afeeIvO/xsyHZRyCkBX7ibwizgBS581vFUKkiJEYJH6wcSsD3c2Sil/bG4S8gWgrldjA7E7CLkVPShfpqYri7jtjkfn3OIH4R958vpnmE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791915542; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=w6BtoRW+1MiLxfbSmGQadwo7l0abOPtZZ54uJBQ5yBg=; b=nZZnoDpmVrDwt1130QkLFkYD1qn6ez9divQ0iWXDot6Xh7XYPeSueIAEynUAVrIZmCd/kks36VkApLVoxEFuKybh4VwPoXAcRtd5tcX3u9HFwnjGuZSBda+/yjfFkA7htR68zj9EGg8BuiXUATERObrZ3dn/sn2Zsz57HXgmr7o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791915542421598.5674049524766; Tue, 13 Oct 2026 11:19:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGh4i-0006vW-Je; Tue, 13 Oct 2026 14:18:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4g-0006uv-FD for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4f-00013t-58 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:06 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-lICvaFhtOqWH9Min4AZBNw-1; Tue, 13 Oct 2026 18:18:00 +0000 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D72F41944B15; Tue, 13 Oct 2026 18:17:59 +0000 (UTC) Received: from localhost (headnet03.pony-001.prod.iad2.dc.redhat.com [10.2.32.114]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 51532195608E; Tue, 13 Oct 2026 18:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791915484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w6BtoRW+1MiLxfbSmGQadwo7l0abOPtZZ54uJBQ5yBg=; b=TUHD+bJPXVG+nSwaVev3TaAxCqK6nnOPVCIep5Hfs6L0S8e6rE2jQKcMs2Ny8YZu9V9y4d itBnnAfZHYoiDrFgdAQlbh3CxD5lJtyM3Ti+X6HMAtMLjtol2nXtD3bTePnumyV75pE0tk glm1Ad8/k1cfr5tKzwf5jEpnmvLDlkE= X-MC-Unique: lICvaFhtOqWH9Min4AZBNw-1 X-Mimecast-MFC-AGG-ID: lICvaFhtOqWH9Min4AZBNw_1791915480 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , akalenyu@redhat.com, Kevin Wolf , eblake@redhat.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , Paolo Bonzini , , Hanna Reitz , Benjamin Marzinski , Stefan Hajnoczi Subject: [PATCH v2 3/8] hw/scsi-disk: move MIG_EVENT_FAILED into a new function Date: Tue, 13 Oct 2026 14:17:47 -0400 Message-ID: <20261013181752.1299456-4-stefanha@redhat.com> In-Reply-To: <20261013181752.1299456-1-stefanha@redhat.com> References: <20261013181752.1299456-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791915545137158500 Content-Type: text/plain; charset="utf-8" Move the MIG_EVENT_FAILED logic from scsi_block_migration_notifier() into its own new scsi_block_migration_failed() function. The next commit adds logic for handling another event, so doing that in dedicated functions makes the code easier to read. Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- hw/scsi/scsi-disk.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index deb33ac1dda..3d88e57eded 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2761,20 +2761,26 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d,= uint32_t tag, uint32_t lun, * fails because the destination may have already preempted and we need to= get * the reservation back. */ +static void scsi_block_migration_failed(SCSIDiskState *s) +{ + SCSIDevice *d =3D &s->qdev; + Error *local_err =3D NULL; + + if (!scsi_generic_pr_state_preempt(d, &local_err)) { + /* MIG_EVENT_FAILED cannot fail, so just warn */ + error_prepend(&local_err, "scsi-block migration rollback: "); + warn_report_err(local_err); + } +} + static int scsi_block_migration_notifier(NotifierWithReturn *notifier, MigrationEvent *e, Error **errp) { - if (e->type =3D=3D MIG_EVENT_FAILED) { - SCSIDiskState *s =3D - container_of(notifier, SCSIDiskState, migration_notifier); - SCSIDevice *d =3D &s->qdev; - Error *local_err =3D NULL; + SCSIDiskState *s =3D + container_of(notifier, SCSIDiskState, migration_notifier); =20 - if (!scsi_generic_pr_state_preempt(d, &local_err)) { - /* MIG_EVENT_FAILED cannot fail, so just warn */ - error_prepend(&local_err, "scsi-block migration rollback: "); - warn_report_err(local_err); - } + if (e->type =3D=3D MIG_EVENT_FAILED) { + scsi_block_migration_failed(s); } return 0; } --=20 2.56.0 From nobody Thu Oct 22 19:27:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791915543; cv=none; d=zohomail.com; s=zohoarc; b=ZYnpG7s5UrRZek8wMgQv4w4fBHboskf7BVGEZj6eErKgiO4bQGQkxC1qDGLJTavXkXdfOOk7xzc71RS1ja6I1g803OIN7Ufv4XWFrzVSlmPDJPzRuACTo28C6DQM3/priqtVFbDKzAHTdbwE1FeF9ZNj9yTVpcrABGdYA9+xF+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791915543; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fTDhqFJn858icFs0AdRVgyT1Kkx7QZzwAc1O/7dJJRw=; b=lecmC7m4GW1FhO4Zvsjwn7eDzoRS0xQTiMIhDIpVclmx8sK48frKZIQg7hiMy2sIldYC8e3ywT54SrGU5QVuvBoME7yaeo5HRUFFJgYFf01EtVaTovGp2jBiE8qjqNHW0l84IsMnb32m4KKahtqKpFSoGBUxxqWJkw8KxcyWzEg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791915543653633.9123919341866; Tue, 13 Oct 2026 11:19:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGh5C-00070x-U6; Tue, 13 Oct 2026 14:18:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4k-0006wG-Hf for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4i-00014J-GD for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:10 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-113-seiJk2ZuMxeUO0UKln7eMg-1; Tue, 13 Oct 2026 18:18:03 +0000 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 28D351828ADE; Tue, 13 Oct 2026 18:18:02 +0000 (UTC) Received: from localhost (headnet03.pony-001.prod.iad2.dc.redhat.com [10.2.32.114]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D5D451800446; Tue, 13 Oct 2026 18:18:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791915487; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fTDhqFJn858icFs0AdRVgyT1Kkx7QZzwAc1O/7dJJRw=; b=GFvmg3Z1gj7ogvDJh3kPWBZl4XsD25dei+eGGMYkP52jrqN7JyhHuNyVUfusXdN10aa3L7 +oMOmgvLs/kM1uYz8XzcwRPmYjbET28DBvKW7tOpwyqpgaDSvy+KwKR+hCl97pB6z/Fsd1 Mpcg0jyVnaRlDig9yLbFD8QjFcSxaYg= X-MC-Unique: seiJk2ZuMxeUO0UKln7eMg-1 X-Mimecast-MFC-AGG-ID: seiJk2ZuMxeUO0UKln7eMg_1791915482 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , akalenyu@redhat.com, Kevin Wolf , eblake@redhat.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , Paolo Bonzini , , Hanna Reitz , Benjamin Marzinski , Stefan Hajnoczi Subject: [PATCH v2 4/8] qemu-pr-helper: add PR_HELPER_CLEANUP for live migration Date: Tue, 13 Oct 2026 14:17:48 -0400 Message-ID: <20261013181752.1299456-5-stefanha@redhat.com> In-Reply-To: <20261013181752.1299456-1-stefanha@redhat.com> References: <20261013181752.1299456-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791915545246158500 Content-Type: text/plain; charset="utf-8" Introduce a new vendor-specific SCSI command that acts similar to REGISTER AND IGNORE EXISTING KEY but also discards multipathd's state (including /etc/multipath/prkeys). This command will be used on the source after live migration completes successfully. This cleanup step is necessary because multipathd will register the key it has stored when the path comes up again. This is undesirable when the guest has migrated to another host and can interfere with the migration process or the application running inside the guest. Add a qemu-pr-manager protocol feature bit indicating that the new PR_HELPER_CLEANUP command is available. The command has no CDB fields other than OPCODE and the response contains no data aside from the usual result and sense data. Note that the linker needs an explicit libmpathcmd dependency for mpath_disconnect() even though qemu-pr-helper.c already #included the mpath_cmd.h header before. Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- v2: - Explicitly reject PR_HELPER_CLEAN commands in scsi_req_new() because this is an internal command that guests cannot send - Add missing "forget" in comment (typo) --- meson.build | 2 + include/scsi/constants.h | 1 + scsi/pr-helper.h | 3 + hw/scsi/scsi-bus.c | 10 +++ scsi/qemu-pr-helper.c | 146 ++++++++++++++++++++++++++++++++++++--- 5 files changed, 153 insertions(+), 9 deletions(-) diff --git a/meson.build b/meson.build index 48da6cf3e6b..6176935082b 100644 --- a/meson.build +++ b/meson.build @@ -1486,6 +1486,8 @@ if host_os =3D=3D 'linux' and have_tools and get_opti= on('mpath').allowed() endif mpathlibs +=3D cc.find_library('multipath', required: get_option('mpath')) + mpathlibs +=3D cc.find_library('mpathcmd', + required: get_option('mpath')) foreach lib: mpathlibs if not lib.found() mpathlibs =3D [] diff --git a/include/scsi/constants.h b/include/scsi/constants.h index 717e470a5d4..bb3981a779b 100644 --- a/include/scsi/constants.h +++ b/include/scsi/constants.h @@ -149,6 +149,7 @@ #define MECHANISM_STATUS 0xbd #define READ_CD 0xbe #define SEND_DVD_STRUCTURE 0xbf +#define PR_HELPER_CLEANUP 0xff /* vendor-specific QEMU command */ =20 /* * SERVICE ACTION IN subcodes diff --git a/scsi/pr-helper.h b/scsi/pr-helper.h index e26e104ec76..d088d0dc193 100644 --- a/scsi/pr-helper.h +++ b/scsi/pr-helper.h @@ -31,6 +31,9 @@ #define PR_HELPER_SENSE_SIZE 96 #define PR_HELPER_DATA_SIZE 8192 =20 +/* Protocol features */ +#define PR_HELPER_FEATURE_CLEANUP (1u << 0) + typedef struct PRHelperResponse { int32_t result; int32_t sz; diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index aa02ff631b7..b4c38c083e1 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -873,6 +873,16 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag,= uint32_t lun, */ !(buf[0] =3D=3D REQUEST_SENSE && d->sense_is_ua))) { ops =3D &reqops_unit_attention; + } else if (buf[0] =3D=3D PR_HELPER_CLEANUP) { + /* + * This is a QEMU-internal vendor-specific SCSI command that must = only + * be submitted directly via blk_aio_ioctl() and not through SCSI + * emulation. Reject the command explicitly to guarantee a guest c= annot + * execute it, although vendor-specific commands are not supported= by + * SCSI emulation (including passthrough) anyway. + */ + trace_scsi_req_parse_bad(d->id, lun, tag, buf[0]); + goto invalid_opcode; } else if (lun !=3D d->lun || buf[0] =3D=3D REPORT_LUNS || (buf[0] =3D=3D REQUEST_SENSE && d->sense_len)) { diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index 9dcd3ec7111..54d196a503f 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -537,6 +537,110 @@ static int coroutine_fn multipath_pr_out(int fd, cons= t uint8_t *cdb, uint8_t *se paramp, noisy, verbose); return mpath_reconstruct_sense(fd, r, sense); } + +/* Get the device-mapper device name given its block device fd */ +static char *get_dm_name(int fd, Error **errp) +{ + struct stat st; + int ret; + + assert(is_mpath(fd)); + + ret =3D fstat(fd, &st); + if (ret !=3D 0) { + error_setg_errno(errp, errno, "fstat failed on fd %d", fd); + return NULL; + } + + return g_strdup_printf("dm-%u", minor(st.st_rdev)); +} + +/* Perform a multipathd command */ +static bool multipathd_cmd(int fd, const char *cmd, Error **errp) +{ + const unsigned int timeout_ms =3D 60000; + char *reply =3D NULL; + int last_errno; + int ret; + + ret =3D mpath_process_cmd(fd, cmd, &reply, timeout_ms); + last_errno =3D errno; + if (reply && strcmp(reply, "ok\n") !=3D 0) { + error_setg(errp, "mpath_process_cmd(%d, \"%s\") replied \"%s\"", + fd, cmd, reply); + free(reply); + return false; + } + free(reply); + if (ret =3D=3D -1) { + error_setg_errno(errp, last_errno, + "mpath_process_cmd(%d, \"%s\") failed", + fd, cmd); + return false; + } + return true; +} + +/* Unregister so this I_T nexus has no key registered anymore */ +static int coroutine_fn multipath_pr_cleanup_unregister(int fd, uint8_t *s= ense, + Error **errp) +{ + uint8_t cdb[PR_HELPER_CDB_SIZE] =3D {}; + uint8_t param[PR_OUT_FIXED_PARAM_SIZE] =3D {}; + + /* Fill in CDB */ + cdb[0] =3D PERSISTENT_RESERVE_OUT; /* OPERATION CODE */ + cdb[1] =3D PRO_REGISTER_AND_IGNORE_EXISTING_KEY; /* SERVICE ACTION */ + stl_be_p(&cdb[5], sizeof(param)); /* PARAMETER LIST LENGT= H */ + + /* The parameter list is all zeroes, so there is nothing to fill in */ + + return multipath_pr_out(fd, cdb, sense, param, sizeof(param)); +} + +/* + * A special version of REGISTER AND IGNORE EXISTING KEY with sark=3D0 to + * unregister the key without triggering multipathd's preemption. This suc= ceeds + * when no key is registered too. This is essential so the migration source + * cleans up its registered key without multipathd preempting the destinat= ion + * host. + */ +static int coroutine_fn multipath_pr_cleanup(int bdev_fd, uint8_t *sense, + Error **errp) +{ + g_autofree char *bdev_dm_name =3D get_dm_name(bdev_fd, errp); + g_autofree char *cmd =3D NULL; + int multipathd_fd; + + if (bdev_dm_name =3D=3D NULL) { + return -1; + } + + /* First make multipathd forget the key and reservation state */ + multipathd_fd =3D mpath_connect(); + if (multipathd_fd =3D=3D -1) { + error_setg_errno(errp, errno, "mpath_connect() failed"); + return -1; + } + + cmd =3D g_strdup_printf("unsetprkey map %s", bdev_dm_name); + if (!multipathd_cmd(multipathd_fd, cmd, errp)) { + mpath_disconnect(multipathd_fd); + return -1; + } + + g_free(cmd); + cmd =3D g_strdup_printf("unsetprstatus map %s", bdev_dm_name); + if (!multipathd_cmd(multipathd_fd, cmd, errp)) { + mpath_disconnect(multipathd_fd); + return -1; + } + + mpath_disconnect(multipathd_fd); + + /* Now unregister the key at the SCSI level */ + return multipath_pr_cleanup_unregister(bdev_fd, sense, errp); +} #endif =20 static int coroutine_fn do_pr_in(int fd, const uint8_t *cdb, uint8_t *sens= e, @@ -578,6 +682,21 @@ static int coroutine_fn do_pr_out(int fd, const uint8_= t *cdb, uint8_t *sense, SG_DXFER_TO_DEV); } =20 +static int coroutine_fn do_pr_cleanup(int fd, uint8_t *sense, Error **errp) +{ + if ((fcntl(fd, F_GETFL) & O_ACCMODE) =3D=3D O_RDONLY) { + scsi_build_sense(sense, SENSE_CODE(INVALID_OPCODE)); + return CHECK_CONDITION; + } + +#ifdef CONFIG_MPATH + if (is_mpath(fd)) { + return multipath_pr_cleanup(fd, sense, errp); + } +#endif + return GOOD; +} + /* Client */ =20 typedef struct PRHelperClient { @@ -667,7 +786,8 @@ static int coroutine_fn prh_read_request(PRHelperClient= *client, } =20 if (req->cdb[0] !=3D PERSISTENT_RESERVE_OUT && - req->cdb[0] !=3D PERSISTENT_RESERVE_IN) { + req->cdb[0] !=3D PERSISTENT_RESERVE_IN && + req->cdb[0] !=3D PR_HELPER_CLEANUP) { error_setg(errp, "Invalid CDB, closing socket."); goto out_close; } @@ -703,7 +823,8 @@ static int coroutine_fn prh_write_response(PRHelperClie= nt *client, ssize_t r; size_t sz; =20 - if (req->cdb[0] =3D=3D PERSISTENT_RESERVE_IN && resp->result =3D=3D GO= OD) { + if (req->cdb[0] =3D=3D PERSISTENT_RESERVE_IN && + resp->result =3D=3D GOOD) { assert(resp->sz <=3D req->sz && resp->sz <=3D sizeof(client->data)= ); } else { assert(resp->sz =3D=3D 0); @@ -739,10 +860,8 @@ static void coroutine_fn prh_co_entry(void *opaque) =20 qio_channel_set_follow_coroutine_ctx(QIO_CHANNEL(client->ioc), true); =20 - /* A very simple negotiation for future extensibility. No features - * are defined so write 0. - */ - flags =3D cpu_to_be32(0); + /* A very simple negotiation for future extensibility */ + flags =3D cpu_to_be32(PR_HELPER_FEATURE_CLEANUP); r =3D qio_channel_write_all(QIO_CHANNEL(client->ioc), (char *) &flags, sizeof(flags), NULL); if (r < 0) { @@ -751,7 +870,7 @@ static void coroutine_fn prh_co_entry(void *opaque) =20 r =3D qio_channel_read_all(QIO_CHANNEL(client->ioc), (char *) &flags, sizeof(flags), NULL); - if (be32_to_cpu(flags) !=3D 0 || r < 0) { + if ((be32_to_cpu(flags) & ~PR_HELPER_FEATURE_CLEANUP) !=3D 0 || r < 0)= { goto out; } =20 @@ -766,15 +885,24 @@ static void coroutine_fn prh_co_entry(void *opaque) } =20 num_active_sockets++; - if (req.cdb[0] =3D=3D PERSISTENT_RESERVE_OUT) { + switch (req.cdb[0]) { + case PERSISTENT_RESERVE_OUT: r =3D do_pr_out(req.fd, req.cdb, resp.sense, client->data, sz); resp.sz =3D 0; - } else { + break; + case PERSISTENT_RESERVE_IN: resp.sz =3D sizeof(client->data); r =3D do_pr_in(req.fd, req.cdb, resp.sense, client->data, &resp.sz); resp.sz =3D MIN(resp.sz, sz); + break; + case PR_HELPER_CLEANUP: + r =3D do_pr_cleanup(req.fd, resp.sense, &local_err); + resp.sz =3D 0; + break; + default: + abort(); } num_active_sockets--; close(req.fd); --=20 2.56.0 From nobody Thu Oct 22 19:27:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791915543; cv=none; d=zohomail.com; s=zohoarc; b=ap9rACT+p37l478aDSOrHxYrTsUmZMH1W8fFo6gerO1azSqe4vQ4Cvkbw9kq01TUuLVQ16EdWBuGfaklDGytQjXHPN5pRb62h4TqXNacyPUy/hXe2BqnywMqCFa45+GkXtiXwLo3W+FF2CpyQqwk/ad8plcN4hhhB5/TAWIYSeU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791915543; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=e2FszP+j+LJd9q+6jyCBEoMTLUNHgvd+OqVEeBa43Yk=; b=OxfHlMJW/GvqjOj82Nwof61MOFGwipi0GqPtdgO88zWbwJdMSDdYn868tVfjBOxSiVNwIA4/KBFVanlq0CbhMchjo6KdB/C853eQ4D5dAmuz+amX0voE0q2vDKCgor26teT9r19cWibbXtDG2KebiU13ZpinfBtBcXOZvPM1AHA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179191554361945.660721133091556; Tue, 13 Oct 2026 11:19:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGh4m-0006xB-75; Tue, 13 Oct 2026 14:18:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4k-0006wE-En for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4i-00014D-Gd for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:09 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-fnaGemL-MRWSaaXKQSY-mA-1; Tue, 13 Oct 2026 18:18:05 +0000 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7E93F19352EB; Tue, 13 Oct 2026 18:18:03 +0000 (UTC) Received: from localhost (headnet03.pony-001.prod.iad2.dc.redhat.com [10.2.32.114]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 32AC2180057E; Tue, 13 Oct 2026 18:18:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791915487; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e2FszP+j+LJd9q+6jyCBEoMTLUNHgvd+OqVEeBa43Yk=; b=PWpg1bXI0v4GMi1Wwrx08s40LUvOMB1qwLDoRPRv+StJSES/26d6nGwpheEugIOtFXjEvq J41hSfCPSX4Y1Nyf56vArXvrKnvbwOzCM46ywgZL+A29yc0hynR2+qEcEVEKsWRc4RjwSk e5Tvvzbepo/AOej+W18sAQNkM/ZoRbo= X-MC-Unique: fnaGemL-MRWSaaXKQSY-mA-1 X-Mimecast-MFC-AGG-ID: fnaGemL-MRWSaaXKQSY-mA_1791915483 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , akalenyu@redhat.com, Kevin Wolf , eblake@redhat.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , Paolo Bonzini , , Hanna Reitz , Benjamin Marzinski , Stefan Hajnoczi Subject: [PATCH v2 5/8] pr-manager-helper: add PR_HELPER_CLEANUP command support Date: Tue, 13 Oct 2026 14:17:49 -0400 Message-ID: <20261013181752.1299456-6-stefanha@redhat.com> In-Reply-To: <20261013181752.1299456-1-stefanha@redhat.com> References: <20261013181752.1299456-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791915545240158500 Content-Type: text/plain; charset="utf-8" qemu-pr-helper now supports the vendor-specific PR_HELPER_CLEANUP SCSI command. Add support to the client side. pr_manager_helper_run() uses scsi_cdb_xfer() to determine the number of bytes to transfer. Extend scsi_cdb_xfer() to know that this vendor-specific command does not transfer any bytes. Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- v2: - Move cdb[0] check after copy from io_hdr - Add missing endianness conversion for protocol flags --- scsi/pr-manager-helper.c | 20 +++++++++++++++++--- scsi/utils.c | 3 +++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c index 26ef3876f0e..e7162e21ff0 100644 --- a/scsi/pr-manager-helper.c +++ b/scsi/pr-manager-helper.c @@ -38,6 +38,8 @@ struct PRManagerHelper { =20 QemuMutex lock; QIOChannel *ioc; + + uint32_t proto_flags; /* flags negotiated with pr-helper */ }; =20 static void pr_manager_send_status_changed_event(PRManagerHelper *pr_mgr) @@ -129,7 +131,9 @@ static int pr_manager_helper_initialize(PRManagerHelper= *pr_mgr, goto out_close; } =20 - flags =3D 0; + pr_mgr->proto_flags =3D be32_to_cpu(flags) & PR_HELPER_FEATURE_CLEANUP; + + flags =3D cpu_to_be32(pr_mgr->proto_flags); r =3D pr_manager_helper_write(pr_mgr, -1, &flags, sizeof(flags), errp); if (r < 0) { goto out_close; @@ -161,9 +165,19 @@ static int pr_manager_helper_run(PRManager *p, } =20 memcpy(cdb, io_hdr->cmdp, io_hdr->cmd_len); - assert(cdb[0] =3D=3D PERSISTENT_RESERVE_OUT || cdb[0] =3D=3D PERSISTEN= T_RESERVE_IN); + assert(cdb[0] =3D=3D PERSISTENT_RESERVE_OUT || + cdb[0] =3D=3D PERSISTENT_RESERVE_IN || + cdb[0] =3D=3D PR_HELPER_CLEANUP); + + /* The command is only available when pr-helper supports it */ + if (cdb[0] =3D=3D PR_HELPER_CLEANUP && + !(pr_mgr->proto_flags & PR_HELPER_FEATURE_CLEANUP)) { + return -ENOTSUP; + } + expected_dir =3D - (cdb[0] =3D=3D PERSISTENT_RESERVE_OUT ? SG_DXFER_TO_DEV : SG_DXFER= _FROM_DEV); + (cdb[0] =3D=3D PERSISTENT_RESERVE_IN ? + SG_DXFER_FROM_DEV : SG_DXFER_TO_DEV); if (io_hdr->dxfer_direction !=3D expected_dir) { return -EINVAL; } diff --git a/scsi/utils.c b/scsi/utils.c index daee90ecf0e..1ee68e68221 100644 --- a/scsi/utils.c +++ b/scsi/utils.c @@ -29,6 +29,9 @@ uint32_t scsi_data_cdb_xfer(uint8_t *buf) =20 uint32_t scsi_cdb_xfer(uint8_t *buf) { + if (buf[0] =3D=3D PR_HELPER_CLEANUP) { + return 0; + } switch (buf[0] >> 5) { case 0: return buf[4]; --=20 2.56.0 From nobody Thu Oct 22 19:27:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791915586; cv=none; d=zohomail.com; s=zohoarc; b=UCEZPObVSuwKZcg+gJZqu3VKmtdWLxG2hcSWPpXOh+IIiyQ0u1ApXmq6QwAgRwulyd9pWTBTWQnKGQHfFVTEpJ391/TsQKFwbYCEd3HOS5zRiUMJDoB7gn6DGCotXM71q2bgVEAjP2ZdFlNnQz1SBuGZlgI/pF7q4nUpZju1BRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791915586; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=p5EsQIfODyO7SmUrEsyt9aN00pLM9//FBxp1hkNZgmw=; b=A2m60phzABbJf0zV+QuUN36w+HG/uvPfN4EgSkQFURLHpgGN++0ivi6DJA7d30fgrhlmWQ3BWBkbYljkZWFePEhG5c+FljXu6CAXLzx82IyGSKy+am/3pOVxsrUi9ZkPJT1aedD1gxX5yQ0+IqA4em2N5OdTgKuLuvOykoT3nKg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791915586261291.3651749923665; Tue, 13 Oct 2026 11:19:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGh5W-0007Ai-S6; Tue, 13 Oct 2026 14:19:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4m-0006xU-GS for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4k-00014u-66 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:11 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-6-D0osUGsDMo-gQvtNdKwv-g-1; Tue, 13 Oct 2026 18:18:05 +0000 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BEE8B1800765; Tue, 13 Oct 2026 18:18:04 +0000 (UTC) Received: from localhost (headnet03.pony-001.prod.iad2.dc.redhat.com [10.2.32.114]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7295B195608E; Tue, 13 Oct 2026 18:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791915489; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p5EsQIfODyO7SmUrEsyt9aN00pLM9//FBxp1hkNZgmw=; b=ZVDu98zMF+0d/q6wj32MX56BuBpXOFIioyHe39SJrgUqdceRwU7brKDhw1Hx2qKog7GWPv DEeRc82bAJaMTeSsBRjSnqGH1lFhNq+gGWKPxsn2RNP2qqYpatSLtWXT6klJwOYeE6XO/s oACswxvnWUOcbEd0nXvjpDAhwR/x2cM= X-MC-Unique: D0osUGsDMo-gQvtNdKwv-g-1 X-Mimecast-MFC-AGG-ID: D0osUGsDMo-gQvtNdKwv-g_1791915484 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , akalenyu@redhat.com, Kevin Wolf , eblake@redhat.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , Paolo Bonzini , , Hanna Reitz , Benjamin Marzinski , Stefan Hajnoczi Subject: [PATCH v2 6/8] file-posix: forward PR_HELPER_CLEANUP commands to pr-manager Date: Tue, 13 Oct 2026 14:17:50 -0400 Message-ID: <20261013181752.1299456-7-stefanha@redhat.com> In-Reply-To: <20261013181752.1299456-1-stefanha@redhat.com> References: <20261013181752.1299456-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791915587849158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- v2: - Ignore PR_HELPER_CLEANUP commands when there is no pr-manager to avoid passing through this QEMU-internal vendor-specific command to the underlying SCSI device. --- block/file-posix.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 328adb57233..df117f35d48 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -4362,12 +4362,20 @@ hdev_co_ioctl(BlockDriverState *bs, unsigned long i= nt req, void *buf) return ret; } =20 - if (req =3D=3D SG_IO && s->pr_mgr) { + if (req =3D=3D SG_IO) { struct sg_io_hdr *io_hdr =3D buf; - if (io_hdr->cmdp[0] =3D=3D PERSISTENT_RESERVE_OUT || - io_hdr->cmdp[0] =3D=3D PERSISTENT_RESERVE_IN) { - return pr_manager_execute(s->pr_mgr, qemu_get_current_aio_cont= ext(), - s->fd, io_hdr); + + if (s->pr_mgr) { + if (io_hdr->cmdp[0] =3D=3D PERSISTENT_RESERVE_OUT || + io_hdr->cmdp[0] =3D=3D PERSISTENT_RESERVE_IN || + io_hdr->cmdp[0] =3D=3D PR_HELPER_CLEANUP) { + return pr_manager_execute(s->pr_mgr, qemu_get_current_aio_= context(), + s->fd, io_hdr); + } + } else if (io_hdr->cmdp[0] =3D=3D PR_HELPER_CLEANUP) { + /* This is a nop without pr-manager */ + io_hdr->status =3D GOOD; + return 0; } } =20 --=20 2.56.0 From nobody Thu Oct 22 19:27:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791915592; cv=none; d=zohomail.com; s=zohoarc; b=TZTGPZygw8DKDGEDzyc7+SO9pzrjXZCJBHFszjY1TbA8kv5/rKqojiEeHiVNDSOxW296IOvDI8WqXInsbu07JB4Vp8p+siK1nwSsbw9BcRxz3/k1vyi9sSUeT5vaQhC/pa/cbr+4+fpc/9kiusakW0EoC9HL07284lhsFfO3hsQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791915592; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cy1sHM4DN9NkFwXyyz8pwoaPUezGhyNbcW8POsu24oY=; b=WYAugMQuhA5b+WXRKJ0cXaIpuGUbhbeh/7HLjXYV7dDuugQngyVXBxNQfNzdk8pRyTsaubf5gid7n3eZ+dKom1ReJ21WgGK9CV3dBDZNKRg/YK2qsjU0YUqUwOgW1e182HKPUW1kWyvjjSH0jNx3XRmC1DUhqnhcdzSzIqIk/9k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791915592988507.5886572540876; Tue, 13 Oct 2026 11:19:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGh5Y-0007Ci-N1; Tue, 13 Oct 2026 14:19:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4r-0006xz-As for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4m-00015M-Bp for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:15 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-61-zbeQCWICNX2BZzwFaIoQdA-1; Tue, 13 Oct 2026 18:18:07 +0000 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0D5281955EB9; Tue, 13 Oct 2026 18:18:06 +0000 (UTC) Received: from localhost (headnet03.pony-001.prod.iad2.dc.redhat.com [10.2.32.114]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B5807180057E; Tue, 13 Oct 2026 18:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791915490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cy1sHM4DN9NkFwXyyz8pwoaPUezGhyNbcW8POsu24oY=; b=QlQ/9N7X/+d/3UpYHyBXidepL3Prj+GdRKaEMnGuxDJqJfLTB2bd1X154P4RqmYZyyEsy0 jI37e8J9aAOq2pyjN9jYV8+S7Dgi8r1ZBo/Jg7cQK+04MwOuNEzZcPwJmto6EAN42t0Z7r oMbUuUgADWlp6DpIkUi1Il5yWYq8PmM= X-MC-Unique: zbeQCWICNX2BZzwFaIoQdA-1 X-Mimecast-MFC-AGG-ID: zbeQCWICNX2BZzwFaIoQdA_1791915486 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , akalenyu@redhat.com, Kevin Wolf , eblake@redhat.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , Paolo Bonzini , , Hanna Reitz , Benjamin Marzinski , Stefan Hajnoczi Subject: [PATCH v2 7/8] scsi: clean up persistent reservation state after migration Date: Tue, 13 Oct 2026 14:17:51 -0400 Message-ID: <20261013181752.1299456-8-stefanha@redhat.com> In-Reply-To: <20261013181752.1299456-1-stefanha@redhat.com> References: <20261013181752.1299456-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791915593994158500 Content-Type: text/plain; charset="utf-8" Live migration of persistent reservations is designed to work without coordination between the source and destination. The destination uses the PREEMPT command to atomically take over the reservation or unregister keys belonging to the source. This approach avoids race conditions where other nodes in the cluster might acquire the reservation and it minimizes communication during the downtime window. While this works at the SCSI level, this approach is incomplete when using multipathd. Multipathd tracks registered keys and automatically registers them again when paths come up. It is unaware that the destination has preempted the reservation and therefore it will still attempt to register the key on the source host. Use the new PR_HELPER_CLEANUP command to communicate with multipathd on the source after migration completes successfully. The effect is similar to REGISTER AND IGNORE EXISTING KEY, except it also discards multipathd's state so that the source will no longer attempt to register the key. PR_HELPER_CLEANUP is a QEMU-internal command that is rejected by scsi_req_new(), so note that this command is not exposed to guests although direct blk_aio_ioctl(SG_IO) calls can make use of it. Buglink: https://redhat.atlassian.net/browse/RHEL-274966 Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- include/hw/scsi/scsi.h | 1 + hw/scsi/scsi-disk.c | 21 ++++++++++++++++++++- hw/scsi/scsi-generic.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index 3eab339b0d2..a2f6f0be7fc 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -256,6 +256,7 @@ SCSIDevice *scsi_device_get(SCSIBus *bus, int channel, = int target, int lun); /* scsi-generic.c. */ extern const SCSIReqOps scsi_generic_req_ops; bool scsi_generic_pr_state_preempt(SCSIDevice *s, Error **errp); +bool scsi_generic_pr_state_cleanup(SCSIDevice *s, Error **errp); =20 /* scsi-disk.c */ #define SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR 0 diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 3d88e57eded..6341089ddf2 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2773,13 +2773,32 @@ static void scsi_block_migration_failed(SCSIDiskSta= te *s) } } =20 +/* + * Unregister keys on the source after migration since the destination has + * preempted and taken over. This cleanup is not necessary at the SCSI lev= el + * but multipathd tracks registered keys and must be informed that this ho= st no + * longer wishes to be registered. + */ +static void scsi_block_migration_done(SCSIDiskState *s) +{ + SCSIDevice *d =3D &s->qdev; + Error *local_err =3D NULL; + + if (!scsi_generic_pr_state_cleanup(d, &local_err)) { + error_prepend(&local_err, "scsi-block migration done: "); + warn_report_err(local_err); + } +} + static int scsi_block_migration_notifier(NotifierWithReturn *notifier, MigrationEvent *e, Error **errp) { SCSIDiskState *s =3D container_of(notifier, SCSIDiskState, migration_notifier); =20 - if (e->type =3D=3D MIG_EVENT_FAILED) { + if (e->type =3D=3D MIG_EVENT_DONE) { + scsi_block_migration_done(s); + } else if (e->type =3D=3D MIG_EVENT_FAILED) { scsi_block_migration_failed(s); } return 0; diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index 153a5275567..e41e973aa92 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -652,6 +652,35 @@ bool scsi_generic_pr_state_preempt(SCSIDevice *s, Erro= r **errp) return true; } =20 +/* Clean up keys on source after migration */ +bool scsi_generic_pr_state_cleanup(SCSIDevice *s, Error **errp) +{ + SCSIPRState *pr_state =3D &s->pr_state; + uint8_t cmd[10] =3D { + PR_HELPER_CLEANUP, /* OPCODE */ + }; + int ret; + + WITH_QEMU_LOCK_GUARD(&pr_state->mutex) { + if (pr_state->key =3D=3D 0) { + return true; /* nothing to do */ + } + } + + ret =3D scsi_SG_IO(s->conf.blk, SG_DXFER_TO_DEV, cmd, sizeof(cmd), NUL= L, 0, + s->io_timeout, errp); + if (ret < 0) { + error_prepend(errp, "pr-helper CLEANUP failed: "); + return false; + } + + WITH_QEMU_LOCK_GUARD(&pr_state->mutex) { + pr_state->key =3D 0; + pr_state->resv_type =3D 0; + } + return true; +} + static void scsi_read_complete(void * opaque, int ret) { SCSIGenericReq *r =3D (SCSIGenericReq *)opaque; --=20 2.56.0 From nobody Thu Oct 22 19:27:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791915607; cv=none; d=zohomail.com; s=zohoarc; b=UekRQaOS3hqWpy7VLKGTSFkEDrmb5W0XCFIqALOGlM6cBx/51hPb0AfEdSxdQpaKqi7o3fXiYBATlgR4SYHBlsz7rXC7CGIfhnktUn0vG4atwxvpup1kZXxfR1qrjxbcMWx/FuDJ28ttyi5913ye28HrEL/FPdH5j4IHoDQKZTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791915607; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wyJrL50gtdvm3FTztrrzURWMCb9Tz1QgOWWG3qZnCgg=; b=NBsY5YF9MuPOPU2ZwV0lfuw9lVXSIgIbh5+huwwDHFyr/NHfGp29XP5bApUACRoVGORfSz1Okw+89bYB+5h8F++3t6EacaceK8oJ8NcUTa+mmXio+IL/z7zaFu3mK6h7CJGF/Ko2RL2PoEYj5oBQCRvkfDQfS41E0eVBe5WZgh0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791915607575344.83147026926986; Tue, 13 Oct 2026 11:20:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGh5T-00078M-Pu; Tue, 13 Oct 2026 14:18:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4o-0006xX-NN for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGh4m-00015V-2L for qemu-devel@nongnu.org; Tue, 13 Oct 2026 14:18:14 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-152-q5DkYkCJO-qHjvrf4LsoDg-1; Tue, 13 Oct 2026 18:18:08 +0000 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 55296195FE27; Tue, 13 Oct 2026 18:18:07 +0000 (UTC) Received: from localhost (headnet03.pony-001.prod.iad2.dc.redhat.com [10.2.32.114]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 088AB1800592; Tue, 13 Oct 2026 18:18:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791915490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wyJrL50gtdvm3FTztrrzURWMCb9Tz1QgOWWG3qZnCgg=; b=NeVpl4NHMuZ4Ai0fpQ99xz28BYmk/COJA51kKczEr8mp6forLf4iFkCmQcmtV5Y1pUqvF3 B/RqA4y0r6hP6QDOu+zWuDVnB5iKCd/IQ4wViSbY0nVWQGIO2z7bRRT/1OrMr+xvGMjery 0wDIHwHaUnDdDgkdkbVOJw5yIa7lEJs= X-MC-Unique: q5DkYkCJO-qHjvrf4LsoDg-1 X-Mimecast-MFC-AGG-ID: q5DkYkCJO-qHjvrf4LsoDg_1791915487 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , akalenyu@redhat.com, Kevin Wolf , eblake@redhat.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , Paolo Bonzini , , Hanna Reitz , Benjamin Marzinski , Stefan Hajnoczi Subject: [PATCH v2 8/8] scsi: use REGISTER AND IGNORE EXISTING KEY for robustness Date: Tue, 13 Oct 2026 14:17:52 -0400 Message-ID: <20261013181752.1299456-9-stefanha@redhat.com> In-Reply-To: <20261013181752.1299456-1-stefanha@redhat.com> References: <20261013181752.1299456-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791915608552158500 Content-Type: text/plain; charset="utf-8" The regular REGISTER service action fails with RESERVATION CONFLICT when the I_T nexus already has a key registered. While we don't expect a key to be registered, it is fragile to rely on this. If there is a key registered for some reason, live migration will fail when the destination hits the RESERVATION CONFLICT error. Use REGISTER AND IGNORE EXISTING KEY so that the command is likely to succeed. Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- hw/scsi/scsi-generic.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index e41e973aa92..e48fcb926f1 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -424,7 +424,8 @@ static void scsi_handle_persistent_reserve_out_reply( } } =20 -static bool scsi_generic_pr_register(SCSIDevice *s, uint64_t key, Error **= errp) +static bool scsi_generic_pr_register_ignore(SCSIDevice *s, uint64_t key, + Error **errp) { uint8_t cmd[10] =3D {}; uint8_t buf[24] =3D {}; @@ -432,14 +433,15 @@ static bool scsi_generic_pr_register(SCSIDevice *s, u= int64_t key, Error **errp) int ret; =20 cmd[0] =3D PERSISTENT_RESERVE_OUT; - cmd[1] =3D PRO_REGISTER; + cmd[1] =3D PRO_REGISTER_AND_IGNORE_EXISTING_KEY; cmd[8] =3D sizeof(buf); memcpy(&buf[8], &key_be, sizeof(key_be)); =20 ret =3D scsi_SG_IO(s->conf.blk, SG_DXFER_TO_DEV, cmd, sizeof(cmd), buf, sizeof(buf), s->io_timeout, errp); if (ret < 0) { - error_prepend(errp, "PERSISTENT RESERVE OUT with REGISTER: "); + error_prepend(errp, "PERSISTENT RESERVE OUT with " + "REGISTER AND IGNORE EXISTING KEY: "); return false; } return true; @@ -620,7 +622,7 @@ bool scsi_generic_pr_state_preempt(SCSIDevice *s, Error= **errp) return true; /* no PR state, do nothing */ } =20 - if (!scsi_generic_pr_register(s, key, errp)) { + if (!scsi_generic_pr_register_ignore(s, key, errp)) { return false; } =20 @@ -647,7 +649,7 @@ bool scsi_generic_pr_state_preempt(SCSIDevice *s, Error= **errp) * CONFLICT is expected if our registration remained in place. */ if (resv_type =3D=3D 0) { - scsi_generic_pr_register(s, key, NULL); + scsi_generic_pr_register_ignore(s, key, NULL); } return true; } --=20 2.56.0 From nobody Thu Oct 22 19:27:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1791988218; cv=none; d=zohomail.com; s=zohoarc; b=QnawaCjQ0Tv/0MU72tIIhTCgw7hxdbT0Ap1Iai0vakz+klQ1abA9xEtPqghDVDDAFermfXqRpwqbnUqOqxhrWROEFBeGjN/mc87c8MVCWBw+P7wAHX4pgCcEcufScD2rfGP8R+xUvaWbtRxPBKoBCpkR4ERT+KgTClab6wICwU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791988218; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Mg9hEvKYQmKTOW2TTZZJGOzdvmEUC5FTIssu/Te77Z8=; b=XmEvCpl+OCPtrS9OLbVXDQSjmVBsMXiw+5nKTEuLaY3obpUyb0yAD7P/pZUOiNB65p7vuOFedmfxj/jrsJO2yLQlpFPqwFyFCyvD0THqQkN9XYfnEaWLl5O3ZMUGp52eYxwTIA2I9HvIMJeNhwq478Up0FEAZgQHHzxRpdvGCs0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791988218737132.92416636331643; Wed, 14 Oct 2026 07:30:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGzyn-0003nw-CU; Wed, 14 Oct 2026 10:29:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGzyg-0003nU-2m for qemu-devel@nongnu.org; Wed, 14 Oct 2026 10:29:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGzyc-0002M0-3K for qemu-devel@nongnu.org; Wed, 14 Oct 2026 10:29:08 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-JtpuyEf0PoGElcnL1JJX_g-1; Wed, 14 Oct 2026 14:29:00 +0000 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4B60B180065F; Wed, 14 Oct 2026 14:28:59 +0000 (UTC) Received: from localhost (headnet05.pony-001.prod.iad2.dc.redhat.com [10.2.32.117]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 41A1126C; Wed, 14 Oct 2026 14:28:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791988144; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mg9hEvKYQmKTOW2TTZZJGOzdvmEUC5FTIssu/Te77Z8=; b=fmN0LOq72pbj8Bg0lp6uqzJJ7+Sf0Jhk78Z0dKsL1oda6nNt6WfoVhlHR1IiMzT6GWPnCD TmzbLFtw8+f841Cf+dW5lh5YgzdViOCCg2RaEFRo0BWfgYdHb5HWatrSRzFZaWErnjosWE IVOezwSUoZaXFw4AtdP2WwlqZQzQeo4= X-MC-Unique: JtpuyEf0PoGElcnL1JJX_g-1 X-Mimecast-MFC-AGG-ID: JtpuyEf0PoGElcnL1JJX_g_1791988139 From: Stefan Hajnoczi To: stefanha@redhat.com Cc: akalenyu@redhat.com, berrange@redhat.com, bmarzins@redhat.com, eblake@redhat.com, fam@euphon.net, hreitz@redhat.com, kwolf@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, pierrick.bouvier@oss.qualcomm.com, qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 9/8] scsi: document PR_HELPER_CLEANUP command Date: Wed, 14 Oct 2026 10:28:47 -0400 Message-ID: <20261014142847.1354701-1-stefanha@redhat.com> In-Reply-To: <20261013181752.1299456-1-stefanha@redhat.com> References: <20261013181752.1299456-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1791988223013158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- docs/interop/pr-helper.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/interop/pr-helper.rst b/docs/interop/pr-helper.rst index e926f0a6c9c..d23c660159e 100644 --- a/docs/interop/pr-helper.rst +++ b/docs/interop/pr-helper.rst @@ -54,7 +54,8 @@ together with the SCSI CDB using ancillary data. The CDB has the following limitations: =20 - the command (stored in the first byte) must be one of 0x5E - (PERSISTENT RESERVE IN) or 0x5F (PERSISTENT RESERVE OUT). + (PERSISTENT RESERVE IN), 0x5F (PERSISTENT RESERVE OUT), or 0xFF (PR HELP= ER + CLEANUP, see below). =20 - the allocation length (stored in bytes 7-8 of the CDB for PERSISTENT RESERVE IN) or parameter list length (stored in bytes 5-8 of the CDB @@ -63,6 +64,16 @@ The CDB has the following limitations: For PERSISTENT RESERVE OUT, the parameter list is sent right after the CDB. The length of the parameter list is taken from the CDB itself. =20 +The PR HELPER CLEANUP command is a vendor-specific command without a param= eter +list that has the following effect on Linux device-mapper multipath device= s and +otherwise has no effect. This command is intended for cleaning up the mult= ipath +device on the source host after live migration has completed successfully: +1. Sends "unsetprkey map " to multipathd. +2. Sends "unsetprstatus map " to multipathd. +3. Performs PERSISTENT RESERVE OUT with the REGISTER AND IGNORE EXISTING K= EY + service action containing zero values for the RESERVATION KEY and SERVI= CE + ACTION RESERVATION KEY. + The helper's reply has the following structure: =20 - 4 bytes for the SCSI status --=20 2.56.0