[PATCH v3 0/2] hw/nvme: add monitor commands for inspecting state

Mateusz Nowicki posted 2 patches 4 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260626112116.7621-1-mateusz.nowicki@posteo.net
Maintainers: "Dr. David Alan Gilbert" <dave@treblig.org>, Keith Busch <kbusch@kernel.org>, Klaus Jensen <its@irrelevant.dk>, Jesper Devantier <foss@defmacro.it>, "Philippe Mathieu-Daudé" <philmd@mailo.com>, Zhao Liu <zhao1.liu@intel.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>
There is a newer version of this series
hmp-commands-info.hx |  32 ++++++++++
hw/nvme/meson.build  |   2 +-
hw/nvme/monitor.c    | 139 +++++++++++++++++++++++++++++++++++++++++++
qapi/machine.json    |  36 +++++++++++
4 files changed, 208 insertions(+), 1 deletion(-)
create mode 100644 hw/nvme/monitor.c
[PATCH v3 0/2] hw/nvme: add monitor commands for inspecting state
Posted by Mateusz Nowicki 4 weeks, 1 day ago
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 v3:
  - Gate the new x-query-nvme[-queues] commands and their 'info'
    counterparts behind CONFIG_NVME_PCI.  They were registered
    unconditionally while the implementations live in hw/nvme/, so
    targets built without NVMe (e.g. riscv64-softmmu) failed to link
    with an undefined reference to qmp_x_query_nvme.
  - hw/nvme/meson.build: keep the source file list alphabetically
    sorted (Markus).

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.

v2: https://lore.kernel.org/qemu-devel/cover.1778694320.git.mateusz.nowicki@posteo.net/
v1: https://lore.kernel.org/qemu-devel/cover.1778409416.git.mateusz.nowicki@posteo.net/

Mateusz Nowicki (2):
  hw/nvme: add 'info nvme' HMP command
  hw/nvme: add 'info nvme-queues' HMP command

 hmp-commands-info.hx |  32 ++++++++++
 hw/nvme/meson.build  |   2 +-
 hw/nvme/monitor.c    | 139 +++++++++++++++++++++++++++++++++++++++++++
 qapi/machine.json    |  36 +++++++++++
 4 files changed, 208 insertions(+), 1 deletion(-)
 create mode 100644 hw/nvme/monitor.c

-- 
2.53.0
Re: [PATCH v3 0/2] hw/nvme: add monitor commands for inspecting state
Posted by Klaus Jensen 3 weeks, 5 days ago
On Jun 26 11:21, Mateusz Nowicki wrote:
> 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 v3:
>   - Gate the new x-query-nvme[-queues] commands and their 'info'
>     counterparts behind CONFIG_NVME_PCI.  They were registered
>     unconditionally while the implementations live in hw/nvme/, so
>     targets built without NVMe (e.g. riscv64-softmmu) failed to link
>     with an undefined reference to qmp_x_query_nvme.
>   - hw/nvme/meson.build: keep the source file list alphabetically
>     sorted (Markus).
> 
> 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.
> 
> v2: https://lore.kernel.org/qemu-devel/cover.1778694320.git.mateusz.nowicki@posteo.net/
> v1: https://lore.kernel.org/qemu-devel/cover.1778409416.git.mateusz.nowicki@posteo.net/
> 
> Mateusz Nowicki (2):
>   hw/nvme: add 'info nvme' HMP command
>   hw/nvme: add 'info nvme-queues' HMP command
> 
>  hmp-commands-info.hx |  32 ++++++++++
>  hw/nvme/meson.build  |   2 +-
>  hw/nvme/monitor.c    | 139 +++++++++++++++++++++++++++++++++++++++++++
>  qapi/machine.json    |  36 +++++++++++
>  4 files changed, 208 insertions(+), 1 deletion(-)
>  create mode 100644 hw/nvme/monitor.c
> 
> -- 
> 2.53.0
> 
> 

With this, my build complains about CONFIG_NVME_PCI being poisoned now:

qapi/qapi-introspect.c:1743:13: error: attempt to use poisoned ‘CONFIG_NVME_PCI’
 1743 | #if defined(CONFIG_NVME_PCI)
      |             ^
In file included from /home/kjensen/src/qemu/include/exec/poison.h:7,
                 from /home/kjensen/src/qemu/include/qemu/osdep.h:38,
                 from qapi/qapi-introspect.c:12:
./config-poison.h:277:20: note: poisoned here
  277 | #pragma GCC poison CONFIG_NVME_PCI
      |                    ^~~~~~~~~~~~~~~
qapi/qapi-introspect.c:1756:13: error: attempt to use poisoned ‘CONFIG_NVME_PCI’
 1756 | #if defined(CONFIG_NVME_PCI)
      |             ^
./config-poison.h:277:20: note: poisoned here
  277 | #pragma GCC poison CONFIG_NVME_PCI
      |                    ^~~~~~~~~~~~~~~

Re: [PATCH v3 0/2] hw/nvme: add monitor commands for inspecting state
Posted by Mateusz Nowicki 3 weeks, 4 days ago
CONFIG_NVME_PCI is poisoned in common code, so the schema 'if' can't work.
v4 drops it: the commands stay unconditional and hw/nvme/monitor-stub.c 
provides
the qmp_x_query_nvme[_queues]() stubs via meson if_false (like 
hw/i386/sgx-stub.c).
Verified it links with and without NVMe (x86_64 / avr).

v4: 
https://lore.kernel.org/qemu-devel/cover.1782819251.git.mateusz.nowicki@posteo.net/

Thanks,
Mateusz

On 6/30/2026 12:31 PM, Klaus Jensen wrote:
> On Jun 26 11:21, Mateusz Nowicki wrote:
>> 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 v3:
>>    - Gate the new x-query-nvme[-queues] commands and their 'info'
>>      counterparts behind CONFIG_NVME_PCI.  They were registered
>>      unconditionally while the implementations live in hw/nvme/, so
>>      targets built without NVMe (e.g. riscv64-softmmu) failed to link
>>      with an undefined reference to qmp_x_query_nvme.
>>    - hw/nvme/meson.build: keep the source file list alphabetically
>>      sorted (Markus).
>>
>> 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.
>>
>> v2: https://lore.kernel.org/qemu-devel/cover.1778694320.git.mateusz.nowicki@posteo.net/
>> v1: https://lore.kernel.org/qemu-devel/cover.1778409416.git.mateusz.nowicki@posteo.net/
>>
>> Mateusz Nowicki (2):
>>    hw/nvme: add 'info nvme' HMP command
>>    hw/nvme: add 'info nvme-queues' HMP command
>>
>>   hmp-commands-info.hx |  32 ++++++++++
>>   hw/nvme/meson.build  |   2 +-
>>   hw/nvme/monitor.c    | 139 +++++++++++++++++++++++++++++++++++++++++++
>>   qapi/machine.json    |  36 +++++++++++
>>   4 files changed, 208 insertions(+), 1 deletion(-)
>>   create mode 100644 hw/nvme/monitor.c
>>
>> -- 
>> 2.53.0
>>
>>
> With this, my build complains about CONFIG_NVME_PCI being poisoned now:
>
> qapi/qapi-introspect.c:1743:13: error: attempt to use poisoned ‘CONFIG_NVME_PCI’
>   1743 | #if defined(CONFIG_NVME_PCI)
>        |             ^
> In file included from /home/kjensen/src/qemu/include/exec/poison.h:7,
>                   from /home/kjensen/src/qemu/include/qemu/osdep.h:38,
>                   from qapi/qapi-introspect.c:12:
> ./config-poison.h:277:20: note: poisoned here
>    277 | #pragma GCC poison CONFIG_NVME_PCI
>        |                    ^~~~~~~~~~~~~~~
> qapi/qapi-introspect.c:1756:13: error: attempt to use poisoned ‘CONFIG_NVME_PCI’
>   1756 | #if defined(CONFIG_NVME_PCI)
>        |             ^
> ./config-poison.h:277:20: note: poisoned here
>    277 | #pragma GCC poison CONFIG_NVME_PCI
>        |                    ^~~~~~~~~~~~~~~
>