Skip to content

RFC hw/nvme: experimental user-creatable objects

Klaus Jensen qemu-devel 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 RFC Latest16 patches 0 repliesNew
  2. v12 patches 2 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16hw/nvme: reattach subsystem namespaces on hotplughw/nvme/subsys.c+9 -10 replies
2/16hw/nvme: change nvme-ns 'shared' defaultdocs/system/devices/nvme.rst hw/core/machine.c hw/nvme/ns.c+18 -180 replies
3/16hw/nvme: move dif/pi prototypes into dif.hhw/nvme/ctrl.c hw/nvme/dif.c hw/nvme/dif.h +1 more+55 -500 replies
4/16hw/nvme: move zns helpers and types into zns.hhw/nvme/ctrl.c hw/nvme/ns.c hw/nvme/nvme.h +1 more+169 -1570 replies
5/16hw/nvme: move zoned namespace members to separate structhw/nvme/ctrl.c hw/nvme/ns.c hw/nvme/nvme.h +2 more+327 -2670 replies
6/16hw/nvme: move nvm namespace members to separate structhw/nvme/ctrl.c hw/nvme/dif.c hw/nvme/dif.h +2 more+290 -2220 replies
7/16hw/nvme: move BlockBackend to NvmeNamespaceNvmhw/nvme/ctrl.c hw/nvme/dif.c hw/nvme/nvme.h+46 -400 replies
8/16hw/nvme: hoist qdev state from namespacehw/nvme/ctrl.c hw/nvme/ns.c hw/nvme/nvme.h +1 more+186 -1550 replies
9/16hw/nvme: hoist qdev state from subsystemhw/nvme/ctrl.c hw/nvme/ns.c hw/nvme/nvme.h +1 more+41 -310 replies
10/16hw/nvme: hoist qdev state from controllerhw/nvme/ctrl.c hw/nvme/dif.c hw/nvme/dif.h +3 more+239 -2090 replies
11/16hw/nvme: add experimental object x-nvme-subsystemhw/nvme/ctrl.c hw/nvme/ns.c hw/nvme/nvme.h +2 more+175 -150 replies
12/16nvme: add structured type for nguidinclude/block/nvme.h+6 -10 replies
13/16hw/nvme: add experimental abstract object x-nvme-nshw/nvme/ns.c hw/nvme/nvme.h hw/nvme/subsys.c +1 more+286 -00 replies
14/16hw/nvme: add experimental objects x-nvme-ns-{nvm, zoned}hw/nvme/ctrl.c hw/nvme/dif.h hw/nvme/meson.build +8 more+1006 -3520 replies
15/16hw/nvme: add experimental device x-nvme-ctrlhw/nvme/ctrl.c hw/nvme/ns.c hw/nvme/nvme.h +1 more+130 -470 replies
16/16docs: add documentation for experimental nvme emulationdocs/system/device-emulation.rst docs/system/devices/nvme-experimental.rst+108 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH RFC v2 00/16] hw/nvme: experimental user-creatable objects

From: Klaus Jensen <[email protected]>

v2
* Use 'zns' instead of 'zoned' for various zns based function name prefixes (Keith)

* Fix the intialization order and get rid of the machine done notifier (Kevin). This requires removing the 'attached-ctrls' parameter and instead controller just attaching to all namespaces in the subsystem. The example below in the cover letter has been updated to reflect this.

Kevin just posted a series that would allow an 'attached-ns' list-style parameter on the device, so this functionality may be added in the future, but let's see if there is actually any request for this.

* Added patch from Hannes to attach namespaces on hotplug (this is also out in non-RFC, but this depends on it, so including it here).

* Added preliminary documentation on the new experimental setup.

Hi,

This is an attempt at adressing a bunch of issues that have presented themselves since we added subsystem support. It's been brewing for a while now.

Fundamentally, I've come to the conclusion that modeling namespaces and subsystems as "devices" is wrong. They should have been user-creatable objects. We've run into multiple issues with wrt. hotplugging due to how namespaces hook up to the controller with a bus. The bus-based design made a lot of sense when we didn't have subsystem support and it follows the design of hw/scsi. But, the problem here is that the bus-based design dictates a one parent relationship, and with shared namespaces, that is just not true. If the namespaces are considered to have a single parent, that parent is the subsystem, not any specific controller.

This series adds a set of experimental user-creatable objects:

-object x-nvme-subsystem
-object x-nvme-ns-nvm
-object x-nvme-ns-zoned

It also adds a new controller device (-device x-nvme-ctrl) that supports these new objects (and gets rid of a bunch of deprecated and confusing parameters). Invoking with an nvme controller now becomes along these lines:

-object x-nvme-subsystem,id=nvme-subsys-0,subnqn=foo
-drive id=blk-nvm-1,file=nvm-1.img,if=none
-object x-nvme-ns-nvm,id=nvme-ns-nvm-1,blockdev=blk-nvm-1,subsys=nvme-subsys-0 -device x-nvme-ctrl,id=nvme-ctrl-0,serial=foo,subsys=nvme-subsys-0

This new approach has a bunch of benefits (other than just fixing the hotplugging issues properly) - we also get support for some nice introspection through some new dynamic properties.

(qemu) qom-get /objects/nvme-subsys-0 controllers [

      "/machine/peripheral/nvme-ctrl-1",
      "/machine/peripheral/nvme-ctrl-0"

]

(qemu) qom-get /objects/nvme-subsys-0 namespaces [

      "/objects/nvme-ns-nvm-1",
      "/objects/nvme-ns-zns-1"

]

(qemu) qom-list /objects/nvme-ns-zns-1
type (string)
subsys (link<x-nvme-subsystem>)
nsid (string)
uuid (string)
eui64 (string)
blockdev (string)
pi-first (bool)
pi-type (NvmeProtInfoType)
extended-lba (bool)
metadata-size (uint16)
lba-size (size)
zone-descriptor-extension-size (size)
zone-cross-read (bool)
zone-max-open (uint32)
zone-capacity (size)
zone-size (size)
zone-max-active (uint32)

(qemu) qom-get /objects/nvme-ns-zns-1 pi-type
"none"

(qemu) qom-get /objects/nvme-ns-zns-1 eui64
"52:54:00:17:67:a0:40:15"

(qemu) qom-get /objects/nvme-ns-zns-1 zone-capacity 12582912

The first patches in this series reorganize a bunch of structs to make it easier to separate them in later patches. Then, it proceeds to hoist the device states into separate structures such that we can reuse the core logic in both the new objects and the existing devices. Thus, full backwards compatibility is kept and the existing device all work as the do prior to this series being applied. I have chosen to separate the nvm and zoned namespace types in to individual objects. The core namespace functionality is contained in an abstract (non user-creatable) x-nvme-ns object and the x-nvme-ns-nvm object extends this and serves at the parent of the x-nvme-ns-zoned object itself.

There are definitely an alternative to this approach - one that I've previously discussed with Hannes (and other QEMU devs, thanks!), and that would be to add the subsystem as a system bus device.

Cheers, Klaus

Hannes Reinecke (1):
hw/nvme: reattach subsystem namespaces on hotplug

Klaus Jensen (15):
hw/nvme: change nvme-ns 'shared' default hw/nvme: move dif/pi prototypes into dif.h hw/nvme: move zns helpers and types into zns.h hw/nvme: move zoned namespace members to separate struct hw/nvme: move nvm namespace members to separate struct hw/nvme: move BlockBackend to NvmeNamespaceNvm hw/nvme: hoist qdev state from namespace hw/nvme: hoist qdev state from subsystem hw/nvme: hoist qdev state from controller hw/nvme: add experimental object x-nvme-subsystem
nvme: add structured type for nguid
hw/nvme: add experimental abstract object x-nvme-ns hw/nvme: add experimental objects x-nvme-ns-{nvm,zoned} hw/nvme: add experimental device x-nvme-ctrl
docs: add documentation for experimental nvme emulation

 docs/system/device-emulation.rst          |    1 +
 docs/system/devices/nvme-experimental.rst |  107 ++
 docs/system/devices/nvme.rst              |   24 +-
 hw/core/machine.c                         |    4 +-
 hw/nvme/ctrl.c                            | 1157 ++++++++++++---------
 hw/nvme/dif.c                             |  120 ++-
 hw/nvme/dif.h                             |   55 +
 hw/nvme/meson.build                       |    2 +-
 hw/nvme/ns-nvm.c                          |  354 +++++++
 hw/nvme/ns-zoned.c                        |  443 ++++++++
 hw/nvme/ns.c                              |  752 ++++++-------
 hw/nvme/nvm.h                             |   65 ++
 hw/nvme/nvme.h                            |  324 ++----
 hw/nvme/subsys.c                          |  240 ++++-
 hw/nvme/zns.h                             |  147 +++
 include/block/nvme.h                      |   11 +-
 qapi/qom.json                             |   82 ++
 softmmu/vl.c                              |    8 +
 18 files changed, 2711 insertions(+), 1185 deletions(-)
 create mode 100644 docs/system/devices/nvme-experimental.rst
 create mode 100644 hw/nvme/dif.h
 create mode 100644 hw/nvme/ns-nvm.c
 create mode 100644 hw/nvme/ns-zoned.c
 create mode 100644 hw/nvme/nvm.h
 create mode 100644 hw/nvme/zns.h
Signature · 1 line
2.33.0