From nobody Mon May 25 21:15:34 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=none dis=none) header.from=posteo.net ARC-Seal: i=1; a=rsa-sha256; t=1778695765; cv=none; d=zohomail.com; s=zohoarc; b=APck4dcGuJEViKgOIup2dOLsV4Iyi8v0ucEYeQAgBNX+E6tjBpX0EPELJ2qKPl0KH4ncv6vk2cZzZP5W7+9nyQEiogvOqdzf2NwZEm5EBbJQ219NG+2mYwpgHiAUdLE24Vrln3WGZ8nmt3tSCsP/RHd+9fEpnUMX8CRwVKameUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778695765; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bKlLd+NN4mOilAk9mAa8lZDncUzkOIyPylj0lXgb184=; b=jq3N0HcvXD0nX+1YDR3fBMs6hVN/YqHxvDeLha2HBpChsBk37KS+jtx0DHf2vuJbenJIsCMIltEkR9aEkbffARFT3J7LLmdknquetf+H2Yjm4zu2If+5T2gJECKzj0gsAY7HYI4k79zYtK79YOlkCAWd3FWsff61pLKA7FwsJaQ= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778695765897446.1769016189023; Wed, 13 May 2026 11:09:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wNE0P-0004fi-Gx; Wed, 13 May 2026 14:08:25 -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 1wNE0J-0004Zy-Hc for qemu-devel@nongnu.org; Wed, 13 May 2026 14:08:20 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wNE0F-0003lI-OF for qemu-devel@nongnu.org; Wed, 13 May 2026 14:08:18 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 81BEB240106 for ; Wed, 13 May 2026 20:08:12 +0200 (CEST) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4gG1fL5JQPz9rxB; Wed, 13 May 2026 20:08:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posteo.net; s=2017; t=1778695692; bh=bKlLd+NN4mOilAk9mAa8lZDncUzkOIyPylj0lXgb184=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=DY6GZE2k3/dXodb6WB7VklS+DSH6xWYvng0rLnMbLy1BxXpHtb/ZaEuGvJ06YbCpz bNFV+Yi9M9Da5GyerZJUY0TQCsA3WWbieamg3Lp1Sk+eEvMfD08D8e/hvGX6r6joh/ zFQeJOjsToF5usr6TgWsgv5S0YCV5Hvx54iexaLQIkW+ELyWUO3l/JtIz3/OCHptV8 Ozf8bEdvt8RTP7neWIClOn/trwnMkqGCpslNAMe3Naj1rVgXymDMgN5b2vtQvOQbUE YperxBV4QY7r2Jbia8aChtRIt+L+hnZ56hvhz4hV56T9X/1gzb/UFghh7FUyYXlWtg gOK2mi2/fti2Q== From: Mateusz Nowicki To: qemu-devel@nongnu.org Cc: Mateusz Nowicki , "Dr. David Alan Gilbert" , Markus Armbruster , Keith Busch , Klaus Jensen , Jesper Devantier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Eric Blake , qemu-block@nongnu.org (open list:nvme) Subject: [PATCH v2 1/2] hw/nvme: add 'info nvme' HMP command Date: Wed, 13 May 2026 18:08:12 +0000 Message-ID: <0b166d66256f1ed20b064acffce38efb52c80c50.1778694320.git.mateusz.nowicki@posteo.net> In-Reply-To: References: 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=lists1p.gnu.org; Received-SPF: pass client-ip=185.67.36.66; envelope-from=mateusz.nowicki@posteo.net; helo=mout02.posteo.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_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.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 @posteo.net) X-ZM-MESSAGEID: 1778695767913158500 Content-Type: text/plain; charset="utf-8" Add an 'info nvme' HMP command for inspecting emulated NVMe controllers from the QEMU monitor. For each NVMe controller in the QOM tree the command prints: - PCI BDF, vendor/device ID and BAR0 base address; - Identify Controller fields visible to the host driver: SN, MN, FR and CNTLID; - the CC, CSTS and AQA registers (raw 32-bit values); - the number of admin and active I/O submission/completion queues. Useful when debugging the Linux NVMe driver against the QEMU emulation without attaching gdb to the QEMU process. Example: (qemu) info nvme /machine/peripheral-anon/device[0] PCI: BDF 00:04.0 VID=3D8086 DID=3D5845 BAR0=3D0x00000000feb50000 ID: SN=3DNVME0001 MN=3DQEMU NVMe Ctrl FR=3D... CNTLID=3D0x0000 CC: 0x00460001 CSTS: 0x00000001 AQA: 0x001f001f Queues: 1 admin + 4 IO SQ / 4 IO CQ Signed-off-by: Mateusz Nowicki Acked-by: Dr. David Alan Gilbert Acked-by: Markus Armbruster --- hmp-commands-info.hx | 13 ++++++++ hw/nvme/meson.build | 2 +- hw/nvme/monitor.c | 76 ++++++++++++++++++++++++++++++++++++++++++++ qapi/machine.json | 17 ++++++++++ 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 hw/nvme/monitor.c diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 82134eb6c21..b984691c3ce 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -340,6 +340,19 @@ SRST Show guest USB devices. ERST =20 + { + .name =3D "nvme", + .args_type =3D "", + .params =3D "", + .help =3D "show emulated NVMe controllers", + .cmd_info_hrt =3D qmp_x_query_nvme, + }, + +SRST + ``info nvme`` + Show emulated NVMe controllers. +ERST + { .name =3D "usbhost", .args_type =3D "", diff --git a/hw/nvme/meson.build b/hw/nvme/meson.build index 7d5caa53c28..33dee048b0a 100644 --- a/hw/nvme/meson.build +++ b/hw/nvme/meson.build @@ -1 +1 @@ -system_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('ctrl.c', 'dif.c', '= ns.c', 'subsys.c', 'nguid.c')) \ No newline at end of file +system_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('ctrl.c', 'dif.c', '= ns.c', 'subsys.c', 'nguid.c', 'monitor.c')) diff --git a/hw/nvme/monitor.c b/hw/nvme/monitor.c new file mode 100644 index 00000000000..95a67544376 --- /dev/null +++ b/hw/nvme/monitor.c @@ -0,0 +1,76 @@ +/* + * QEMU NVMe Controller monitor commands + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-machine.h" +#include "qapi/type-helpers.h" +#include "hw/pci/pci.h" + +#include "nvme.h" + +static int collect_one(Object *obj, void *opaque) +{ + GString *buf =3D opaque; + NvmeCtrl *n; + PCIDevice *pci; + pcibus_t bar0; + unsigned io_sq =3D 0, io_cq =3D 0; + + if (!object_dynamic_cast(obj, TYPE_NVME)) { + return 0; + } + n =3D NVME(obj); + pci =3D PCI_DEVICE(n); + bar0 =3D pci_get_bar_addr(pci, 0); + + for (unsigned i =3D 1; i <=3D n->params.max_ioqpairs; i++) { + if (n->sq && n->sq[i]) { + io_sq++; + } + if (n->cq && n->cq[i]) { + io_cq++; + } + } + + g_string_append_printf(buf, "%s\n", object_get_canonical_path(obj)); + g_string_append_printf(buf, + " PCI: BDF %02x:%02x.%x VID=3D%04x DID=3D%04x ", + pci_dev_bus_num(pci), PCI_SLOT(pci->devfn), PCI_FUNC(pci->devfn), + pci_get_word(pci->config + PCI_VENDOR_ID), + pci_get_word(pci->config + PCI_DEVICE_ID)); + if (bar0 =3D=3D PCI_BAR_UNMAPPED) { + g_string_append(buf, "BAR0=3Dunmapped\n"); + } else { + g_string_append_printf(buf, "BAR0=3D0x%016" PRIx64 "\n", + (uint64_t)bar0); + } + g_string_append_printf(buf, + " ID: SN=3D%.20s MN=3D%.40s FR=3D%.8s CNTLID=3D0x%04x\n", + n->id_ctrl.sn, n->id_ctrl.mn, n->id_ctrl.fr, n->cntlid); + g_string_append_printf(buf, " CC: 0x%08x\n", + ldl_le_p(&n->bar.cc)); + g_string_append_printf(buf, " CSTS: 0x%08x\n", + ldl_le_p(&n->bar.csts)); + g_string_append_printf(buf, " AQA: 0x%08x\n", + ldl_le_p(&n->bar.aqa)); + g_string_append_printf(buf, + " Queues: 1 admin + %u IO SQ / %u IO CQ\n", io_sq, io_cq); + return 0; +} + +HumanReadableText *qmp_x_query_nvme(Error **errp) +{ + g_autoptr(GString) buf =3D g_string_new(""); + + object_child_foreach_recursive(object_get_root(), collect_one, buf); + + if (buf->len =3D=3D 0) { + g_string_append(buf, "no NVMe controllers\n"); + } + + return human_readable_text_from_str(buf); +} diff --git a/qapi/machine.json b/qapi/machine.json index 685e4e29b87..d4a589e7681 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1772,6 +1772,23 @@ 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } =20 +## +# @x-query-nvme: +# +# Query state of emulated NVMe controllers. +# +# Features: +# +# @unstable: This command is meant for debugging. +# +# Returns: NVMe controller state as human-readable text +# +# Since: 11.1 +## +{ 'command': 'x-query-nvme', + 'returns': 'HumanReadableText', + 'features': [ 'unstable' ] } + ## # @SmbiosEntryPointType: # --=20 2.53.0 From nobody Mon May 25 21:15:34 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=none dis=none) header.from=posteo.net ARC-Seal: i=1; a=rsa-sha256; t=1778695758; cv=none; d=zohomail.com; s=zohoarc; b=lo3fs6X8m/9StOD8gjNrHngCGa3dmK7abSeSqrzhUH2k0xKkCFaoc29WbykcuqBphZgExH+J+RcMeHvNsIcHAtEJ0/P3kutTKRPLScP7j8IEfRRgrAt5gGBW4FXLFpCzW0vlcyd1/QMnpXdhDDMqsUzU5NPo54dLumbaT+rpMtk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778695758; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=S393Oj9hKKj+jcfoTeUam2+mFKNsqsbhkOfuHcn9dgU=; b=grS7Ke6sBFJ2pzepbP8SwCCwMer+J7+UxqmcJU/N2nLAl+zGDm/cI4eOE/K+WI1XJIJXyAm9a2vNdcsmSCUxJEtYqeRjZTeyxRRzZPfuRmzwHR7uHzNQp43zOIlUxe+wI9eCJwqRLVqKptKpUTDFnO7y5VvRJ8yKssGSpr/1Hjs= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778695758599280.6130463520319; Wed, 13 May 2026 11:09:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wNE0N-0004es-8A; Wed, 13 May 2026 14:08:23 -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 1wNE0J-0004a0-JQ for qemu-devel@nongnu.org; Wed, 13 May 2026 14:08:20 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wNE0F-0003lV-OJ for qemu-devel@nongnu.org; Wed, 13 May 2026 14:08:18 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 79B61240105 for ; Wed, 13 May 2026 20:08:13 +0200 (CEST) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4gG1fN1GZpz9rxL; Wed, 13 May 2026 20:08:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posteo.net; s=2017; t=1778695693; bh=S393Oj9hKKj+jcfoTeUam2+mFKNsqsbhkOfuHcn9dgU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=FHPMWa3i2rltKrSb912w2QZItHrbIQJ1K+2/9H/zqopwrQxKmv2fDdAp8RQyOHtn0 H+g0qsdfXuw13kDl4qmodcjRggRBTeVmSPcig8xNwVjJxNPLgfnzs7TspcHIxTRMdh NfIyJHsX/BRvvhydGxcOK38+LUaiYw97aPkrzELQBuw/TluQ+UuI0fBIsIPto5Md5R z9zqBLl13HEZIaMWqDnm5ZK/uaz5E3fAxt8fB3MiIqLKahOo7uj7tIF95J3hRgdPRI t8st6p0aGjmmq77ezpxU2YGvnxleW1HeX8Tq8mmqu95kI76NG2l1Vowrf60Rk1esmK 8Zm3EdqVvX59g== From: Mateusz Nowicki To: qemu-devel@nongnu.org Cc: Mateusz Nowicki , "Dr. David Alan Gilbert" , Markus Armbruster , Keith Busch , Klaus Jensen , Jesper Devantier , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , qemu-block@nongnu.org (open list:nvme) Subject: [PATCH v2 2/2] hw/nvme: add 'info nvme-queues' HMP command Date: Wed, 13 May 2026 18:08:13 +0000 Message-ID: In-Reply-To: References: 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=lists1p.gnu.org; Received-SPF: pass client-ip=185.67.36.66; envelope-from=mateusz.nowicki@posteo.net; helo=mout02.posteo.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_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.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 @posteo.net) X-ZM-MESSAGEID: 1778695760026158500 Content-Type: text/plain; charset="utf-8" Add an 'info nvme-queues' HMP command that lists, for every emulated NVMe controller, the admin SQ/CQ and every active I/O SQ/CQ. For each queue the command prints: - the ring size, head and tail indices; - the associated CQ id (for SQ) or interrupt vector (for CQ); - the queue's PRP1 (DMA base address of the ring); - the BAR0-relative doorbell offset (SQyTDBL / CQyHDBL); - the current CQ phase tag. The doorbell offsets are computed from CAP.DSTRD so they remain correct if the emulation ever exposes a non-zero stride. Useful when debugging the Linux NVMe driver against the QEMU emulation - queue setup, doorbell rings, AERs held in the admin SQ etc. - without attaching gdb to the QEMU process. Example, with the long PRP1 ring address and BAR0-relative doorbell offset replaced by '...'; phase tag column omitted for brevity: (qemu) info nvme-queues /machine/peripheral-anon/device[0] SQ 0 size=3D32 head=3D9 tail=3D9 cqid=3D0 prp1=3D... SQTD= BL=3D... CQ 0 size=3D32 head=3D8 tail=3D8 iv=3D0 prp1=3D... CQHD= BL=3D... SQ 1 size=3D1024 head=3D2 tail=3D2 cqid=3D1 prp1=3D... SQTD= BL=3D... CQ 1 size=3D1024 head=3D2 tail=3D2 iv=3D1 prp1=3D... CQHD= BL=3D... Signed-off-by: Mateusz Nowicki Acked-by: Dr. David Alan Gilbert Acked-by: Markus Armbruster --- hmp-commands-info.hx | 15 +++++++++++ hw/nvme/monitor.c | 63 ++++++++++++++++++++++++++++++++++++++++++++ qapi/machine.json | 17 ++++++++++++ 3 files changed, 95 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index b984691c3ce..874c1e19707 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -353,6 +353,21 @@ SRST Show emulated NVMe controllers. ERST =20 + { + .name =3D "nvme-queues", + .args_type =3D "", + .params =3D "", + .help =3D "show active NVMe queues and their doorbells", + .cmd_info_hrt =3D qmp_x_query_nvme_queues, + }, + +SRST + ``info nvme-queues`` + Show all active NVMe submission and completion queues, including + head/tail, DMA address of the ring and BAR0-relative doorbell + offset. +ERST + { .name =3D "usbhost", .args_type =3D "", diff --git a/hw/nvme/monitor.c b/hw/nvme/monitor.c index 95a67544376..c8161943c08 100644 --- a/hw/nvme/monitor.c +++ b/hw/nvme/monitor.c @@ -74,3 +74,66 @@ HumanReadableText *qmp_x_query_nvme(Error **errp) =20 return human_readable_text_from_str(buf); } + +static void append_sq(GString *buf, NvmeSQueue *sq, unsigned stride) +{ + hwaddr db_off =3D 0x1000 + 2 * sq->sqid * stride; + + g_string_append_printf(buf, + " SQ %u size=3D%-5u head=3D%-5u tail=3D%-5u cqid=3D%-3u " + "prp1=3D0x%016" PRIx64 " SQTDBL=3DBAR0+0x%03" HWADDR_PRIx "\n", + sq->sqid, sq->size, sq->head, sq->tail, sq->cqid, + sq->dma_addr, db_off); +} + +static void append_cq(GString *buf, NvmeCQueue *cq, unsigned stride) +{ + hwaddr db_off =3D 0x1000 + (2 * cq->cqid + 1) * stride; + + g_string_append_printf(buf, + " CQ %u size=3D%-5u head=3D%-5u tail=3D%-5u iv=3D%-5u " + "prp1=3D0x%016" PRIx64 " CQHDBL=3DBAR0+0x%03" HWADDR_PRIx + " phaseTag=3D%u\n", + cq->cqid, cq->size, cq->head, cq->tail, cq->vector, + cq->dma_addr, db_off, cq->phase); +} + +static int collect_queues(Object *obj, void *opaque) +{ + GString *buf =3D opaque; + NvmeCtrl *n; + unsigned stride; + + if (!object_dynamic_cast(obj, TYPE_NVME)) { + return 0; + } + n =3D NVME(obj); + stride =3D 4u << NVME_CAP_DSTRD(ldq_le_p(&n->bar.cap)); + + g_string_append_printf(buf, "%s\n", object_get_canonical_path(obj)); + append_sq(buf, &n->admin_sq, stride); + append_cq(buf, &n->admin_cq, stride); + + for (unsigned i =3D 1; i <=3D n->params.max_ioqpairs; i++) { + if (n->sq && n->sq[i]) { + append_sq(buf, n->sq[i], stride); + } + if (n->cq && n->cq[i]) { + append_cq(buf, n->cq[i], stride); + } + } + return 0; +} + +HumanReadableText *qmp_x_query_nvme_queues(Error **errp) +{ + g_autoptr(GString) buf =3D g_string_new(""); + + object_child_foreach_recursive(object_get_root(), collect_queues, buf); + + if (buf->len =3D=3D 0) { + g_string_append(buf, "no NVMe controllers\n"); + } + + return human_readable_text_from_str(buf); +} diff --git a/qapi/machine.json b/qapi/machine.json index d4a589e7681..c21b128e0a9 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1789,6 +1789,23 @@ 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } =20 +## +# @x-query-nvme-queues: +# +# Query state of all active SQ/CQ for emulated NVMe controllers. +# +# Features: +# +# @unstable: This command is meant for debugging. +# +# Returns: per-queue state as human-readable text +# +# Since: 11.1 +## +{ 'command': 'x-query-nvme-queues', + 'returns': 'HumanReadableText', + 'features': [ 'unstable' ] } + ## # @SmbiosEntryPointType: # --=20 2.53.0