From nobody Sat Feb 7 07:11:30 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632468902034707.7484875344554; Fri, 24 Sep 2021 00:35:02 -0700 (PDT) Received: from localhost ([::1]:53082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTfjY-0005hD-Ko for importer@patchew.org; Fri, 24 Sep 2021 03:35:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTfcb-000392-FB; Fri, 24 Sep 2021 03:27:49 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:36137) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTfcZ-0002pH-LQ; Fri, 24 Sep 2021 03:27:49 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id E4A265C020E; Fri, 24 Sep 2021 03:27:46 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 24 Sep 2021 03:27:46 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 24 Sep 2021 03:27:45 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=5yt5X09LNjNuE xr0Bi0xN0yrJWRZcc+WYIN5acFZcVY=; b=hsyOXxFybqwTCRSUELpmusmL7IgUO 3TfdBgoMwwzoX0bIUXjNcBfia5RrzNM6KUnwNaupPfrd4SKfu17q3mYosUWjUr8U iXvFVVDDHBrdqXcAFUGJZagi7OrYDaKrE/GAZFic1v1xWzw3IH/E3KU1Qo9UyK5p EkGNPLWNS5uhdhjFiIqWIy8P/9XTEpqO2UA3dl12Ek6Nyje9x9Cux7bU7VajlxfO oQcn+rnd/e+/izn2zQsW3GGrIDZxySMLkyjnjIhyr8MQf05Se5M0Y4aEIO3bTZZS D58XQuugkskTXpI7u2QEFXYt4j4Y2nBu9WHnho4gY+bEkqjW2vJlZFU8g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=5yt5X09LNjNuExr0Bi0xN0yrJWRZcc+WYIN5acFZcVY=; b=IjbUGsNH gAzXNk+PKFM/QPrCKIl6BRVnzBx1neWLUyokulIsZHxVaAkn8d99ICPzm43M1mY4 mqrO0HJTMox5F6DrOPExa38jAEkrGTpU06fxtcv00PAJEX/DoDJLwLHmQgyWdmWQ OJW3h4s/q2h3V/GIYpfJjYyzTa2fxw4jhg4WLFSg/IWeQvTHwJbFOmMi1BRX2hWN X5dnlxrc41sliWUmxjfOFbtR2f4fxO+Pb7CJfj1FHaHHpE592cSdnxpAL6jrvWAD RbubVtUfSWOJpMOG6yctEdieMrlL0Ndb7XNyGmRmzwYnodA5N+IJko7cU0fT7WVN kfcAYlUQbSDC6w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejtddguddujecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepueelteegieeuhffgkeefgfevjeeigfetkeeitdfgtdeifefhtdfhfeeuffev gfeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepih htshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org Subject: [PATCH 1/2] hw/nvme: reattach subsystem namespaces on hotplug Date: Fri, 24 Sep 2021 09:27:41 +0200 Message-Id: <20210924072742.306473-2-its@irrelevant.dk> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210924072742.306473-1-its@irrelevant.dk> References: <20210924072742.306473-1-its@irrelevant.dk> 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=66.111.4.27; envelope-from=its@irrelevant.dk; helo=out3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham 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: Eduardo Habkost , qemu-block@nongnu.org, Klaus Jensen , Keith Busch , Hannes Reinecke , Klaus Jensen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1632468903017100001 Content-Type: text/plain; charset="utf-8" From: Hannes Reinecke With commit 5ffbaeed16 ("hw/nvme: fix controller hot unplugging") namespaces get moved from the controller to the subsystem if one is specified. That keeps the namespaces alive after a controller hot-unplug, but after a controller hotplug we have to reconnect the namespaces from the subsystem to the controller. Fixes: 5ffbaeed16 ("hw/nvme: fix controller hot unplugging") Cc: Klaus Jensen Signed-off-by: Hannes Reinecke [k.jensen: only attach to shared and non-detached namespaces] Signed-off-by: Klaus Jensen --- hw/nvme/subsys.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c index 93c35950d69d..6b2e4c975f5b 100644 --- a/hw/nvme/subsys.c +++ b/hw/nvme/subsys.c @@ -14,7 +14,7 @@ int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp) { NvmeSubsystem *subsys =3D n->subsys; - int cntlid; + int cntlid, nsid; =20 for (cntlid =3D 0; cntlid < ARRAY_SIZE(subsys->ctrls); cntlid++) { if (!subsys->ctrls[cntlid]) { @@ -29,12 +29,20 @@ int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp) =20 subsys->ctrls[cntlid] =3D n; =20 + for (nsid =3D 1; nsid < ARRAY_SIZE(subsys->namespaces); nsid++) { + NvmeNamespace *ns =3D subsys->namespaces[nsid]; + if (ns && ns->params.shared && !ns->params.detached) { + nvme_attach_ns(n, ns); + } + } + return cntlid; } =20 void nvme_subsys_unregister_ctrl(NvmeSubsystem *subsys, NvmeCtrl *n) { subsys->ctrls[n->cntlid] =3D NULL; + n->cntlid =3D -1; } =20 static void nvme_subsys_setup(NvmeSubsystem *subsys) --=20 2.33.0