hw/nvme: add monitor commands for inspecting state
v2 cover hw/nvme: add monitor commands for inspecting state
Add two HMP commands for inspecting emulated NVMe controllers from the QEMU monitor without attaching gdb to the QEMU process:
- 'info nvme' - per-controller summary (PCI, identify
fields, CC/CSTS/AQA, queue counts)
- 'info nvme-queues' - per-queue listing of admin and I/O SQ/CQ (size, head/tail, PRP1, doorbell offset, phase tag)
Useful for verifying queue setup, doorbell rings, AERs held in the admin SQ and similar driver/controller interaction details from a running QEMU monitor.
Changes in v2:
- hw/nvme/meson.build: add the missing trailing newline (Markus).
- Pick up Acked-by tags from Dr. David Alan Gilbert and Markus Armbruster on both patches.
v1: https://lore.kernel.org/qemu-devel/[email protected]/
Mateusz Nowicki (2):
hw/nvme: add 'info nvme' HMP command
hw/nvme: add 'info nvme-queues' HMP command
hmp-commands-info.hx | 28 +++++++++ hw/nvme/meson.build | 2 +- hw/nvme/monitor.c | 139 +++++++++++++++++++++++++++++++++++++++++++ qapi/machine.json | 34 +++++++++++ 4 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 hw/nvme/monitor.c
Signature · 1 line
2.53.0
PATCH v2 2/2 hw/nvme: add 'info nvme-queues' HMP command
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=32 head=9 tail=9 cqid=0 prp1=... SQTDBL=... CQ 0 size=32 head=8 tail=8 iv=0 prp1=... CQHDBL=... SQ 1 size=1024 head=2 tail=2 cqid=1 prp1=... SQTDBL=... CQ 1 size=1024 head=2 tail=2 iv=1 prp1=... CQHDBL=...
--- hmp-commands-info.hx | 15 +++++++++++ hw/nvme/monitor.c | 63 ++++++++++++++++++++++++++++++++++++++++++++ qapi/machine.json | 17 ++++++++++++ 3 files changed, 95 insertions(+)
hmp-commands-info.hx +15 -0
@@ -353,6 +353,21 @@ SRST Show emulated NVMe controllers. ERST + { + .name = "nvme-queues", + .args_type = "", + .params = "", + .help = "show active NVMe queues and their doorbells", + .cmd_info_hrt = 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 = "usbhost", .args_type = "",
hw/nvme/monitor.c +63 -0
66 lines not on this page · raw message
qapi/machine.json +17 -0
@@ -1789,6 +1789,23 @@ 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } +## +# @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: #
Signature · 1 line
2.53.0
PATCH v2 1/2 hw/nvme: add 'info nvme' HMP command
In reply to Mateusz NowickiAdd 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=8086 DID=5845 BAR0=0x00000000feb50000
ID: SN=NVME0001 MN=QEMU NVMe Ctrl FR=... CNTLID=0x0000
CC: 0x00460001
CSTS: 0x00000001
AQA: 0x001f001fQueues: 1 admin + 4 IO SQ / 4 IO CQ
--- 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
hmp-commands-info.hx +13 -0
@@ -340,6 +340,19 @@ SRST Show guest USB devices. ERST + { + .name = "nvme", + .args_type = "", + .params = "", + .help = "show emulated NVMe controllers", + .cmd_info_hrt = qmp_x_query_nvme, + }, + +SRST + ``info nvme`` + Show emulated NVMe controllers. +ERST + { .name = "usbhost", .args_type = "",
hw/nvme/meson.build +1 -1
@@ -1 +1 @@ -system_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('ctrl.c', 'dif.c', 'ns.c', 'subsys.c', 'nguid.c')) +system_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('ctrl.c', 'dif.c', 'ns.c', 'subsys.c', 'nguid.c', 'monitor.c'))
hw/nvme/monitor.c new file +76 -0
76 lines not on this page · raw message
qapi/machine.json +17 -0
@@ -1772,6 +1772,23 @@ 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } +## +# @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: #
Signature · 1 line
2.53.0
Quoted 9 lines · Mateusz Nowicki
Add two HMP commands for inspecting emulated NVMe controllers from the QEMU monitor without attaching gdb to the QEMU process:
- 'info nvme' - per-controller summary (PCI, identify
fields, CC/CSTS/AQA, queue counts)
- 'info nvme-queues' - per-queue listing of admin and I/O SQ/CQ (size, head/tail, PRP1, doorbell offset, phase tag)
Quoted 3 lines
Useful for verifying queue setup, doorbell rings, AERs held in the admin SQ and similar driver/controller interaction details from a running QEMU monitor.
I can take this, but I'd like at least an Acked-by from an NVME maintainer.