From nobody Mon May 6 08:04:59 2024 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=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1631180685; cv=none; d=zohomail.com; s=zohoarc; b=L/Dr2LS+vtog6IpXL1WJhLwvBtkbmmlSA8CbFzNOgpogW9JqLmFwvBYa201J3hsTFp3Oo5zL2rBgpxF9TWNY4y28nEp9YtcNGcMu3tx44tYtgSK+1rhb0J3lSNCjHv/fExTJNvVC9s8Q6iUMuk9bnUd+U4F0JPBKltpqbyKLDxc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631180685; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=lcVS1bYtum7n0wWFZtQaap94bm7XcrdkvpMEeUHSEr0=; b=AmfP4nL3r+L+qakqczFxXNhFY9Edk0VZAcXRK0FZcuD/T7QyhxdtKvJ0eR8IcGJt99AeyUkT74ddgMjRz20uEYtIJILXysu0dTOAIafKKcERppM1JrS+Sstuh+NW2fSeQIpAigCbXnA7qWE8RacrrBLFUFXSktZ/AzE4ZuXXmdY= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631180685346548.0437539432454; Thu, 9 Sep 2021 02:44:45 -0700 (PDT) Received: from localhost ([::1]:56056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOGbs-00089T-0o for importer@patchew.org; Thu, 09 Sep 2021 05:44:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOGaO-00060r-TM; Thu, 09 Sep 2021 05:43:12 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:42278) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOGaN-0001Cp-9e; Thu, 09 Sep 2021 05:43:12 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id DB7A322322; Thu, 9 Sep 2021 09:43:09 +0000 (UTC) Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id D5497A3BF0; Thu, 9 Sep 2021 09:43:09 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id C789E518E2AF; Thu, 9 Sep 2021 11:43:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1631180589; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=lcVS1bYtum7n0wWFZtQaap94bm7XcrdkvpMEeUHSEr0=; b=Lga9Tl2UZq0V3RCDoPyJECgu1N3RKhpxSfw+uh9lkC136jaOXvyP8zMZ7dVDVpE2mSabGa c6T3PUZLc54Y2TD2y9T8W59eg+xh4Bedw9LTaEf28idZwYVLKd4UKBRSwp0bnMRyDEaCQH KvJx0YXf62tYTeydKT14AeVvZkn8LTE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1631180589; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=lcVS1bYtum7n0wWFZtQaap94bm7XcrdkvpMEeUHSEr0=; b=/4hBLg/E7OKVYDLZfSi+u9YNnVNdcsoVOdy7NzBVY51gxmaAisYYL+7bAaHTa9+WGa1MMp AfAvh6sUA6N4jNAg== From: Hannes Reinecke To: Klaus Jensen Subject: [PATCH] hw/nvme: reattach subsystem namespaces on hotplug Date: Thu, 9 Sep 2021 11:43:08 +0200 Message-Id: <20210909094308.122038-1-hare@suse.de> X-Mailer: git-send-email 2.29.2 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=195.135.220.28; envelope-from=hare@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_NONE=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: qemu-devel@nongnu.org, qemu-block@nongnu.org, Hannes Reinecke Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1631180686709100001 Content-Type: text/plain; charset="utf-8" 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 --- hw/nvme/subsys.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c index 93c35950d6..a9404f2b5e 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,18 @@ int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp) =20 subsys->ctrls[cntlid] =3D n; =20 + for (nsid =3D 0; nsid < ARRAY_SIZE(subsys->namespaces); nsid++) { + if (subsys->namespaces[nsid]) { + nvme_attach_ns(n, subsys->namespaces[nsid]); + } + } 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.26.2