From patchwork Mon Sep 27 05:17:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 12519105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 380D2C433F5 for ; Mon, 27 Sep 2021 05:23:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AC33F60FED for ; Mon, 27 Sep 2021 05:23:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AC33F60FED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=irrelevant.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:41598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUj6h-0006nA-HP for qemu-devel@archiver.kernel.org; Mon, 27 Sep 2021 01:23:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUj1o-0002Xt-Sa; Mon, 27 Sep 2021 01:18:12 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:36293) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUj1l-0008FJ-EE; Mon, 27 Sep 2021 01:18:11 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id B8C512B011FC; Mon, 27 Sep 2021 01:18:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 27 Sep 2021 01:18:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:content-type:mime-version :content-transfer-encoding; s=fm1; bh=t78vfTUGeTLCIFrKtCCBCYtotE 9BeXII9h6fhKIW4yU=; b=O6FIY4Yfo28rHBswdLkA6VPyvHvMEJe2zuzXY30Ty6 4o0liKgKjotCrbQP/Lp2RLn569aChDvx72xOXA9p3vYap5AEumNGPDsH0qoNP63E P2BUde+gChSnEdFAEa6WT+fXBy6/qXnhK1zhEU/Hw77tLklgEcgBQsxNerbH1+Fw ArKZ4+h4g/Zeq2bS+Y6FblQgmBwPzIj2+Ju/+OHgPAo99yMf0pSmOYcZVld/YeZ2 UoJ2nzfnm8+DBFeZ8FMVe6hlTW4H09+GTtZMqG6BSWxj9tXRlmoOC2fPdUrJI+Qj 02vVBEx9N/jJUvtIYtmGTh6SSdrGsFwYbVKel6OFfCXg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=t78vfT UGeTLCIFrKtCCBCYtotE9BeXII9h6fhKIW4yU=; b=WhNGsF37vq+q+JJrwqyDzj BIOM3tZe3E3c9lBfeEeKV5l9zmrWRqZMsml+kMAxhsUsPIFIFU1Mn+98uusdEueX +3uESCSK3UnR/s6nR8PAwmVPqHL6EnJXfeNC0aH890qwedTcCwHzlUwGu+a0z2+f 6BUu2FnKqLdyAKVOAkbewQaL1Mj90fa6mLxCz/AHG1XWInplaV+saBp5+ImCX6h3 XRMvoEWbA1dB855GONViCRGHQIkMaDM8I+0o9kCsbo3YAOiPJhye/bZsBkblvv5Q 5fJU+dM0AHQy8IgmTa+5dfJzQ/1RLAiM6kYGQRUTJG4+fhvVzsFwnh4AJ4Gm2VWQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejjedgledvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffotggggfesthhqredtredtjeenucfhrhhomhepmfhlrghushcu lfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrthhtvg hrnhephfegveekiefgkeevvdetjeejkeekudfgvdehieejfffgkeffvdevlefftedvgefh necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhtsh esihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 27 Sep 2021 01:18:01 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Subject: [PATCH RFC v2 00/16] hw/nvme: experimental user-creatable objects Date: Mon, 27 Sep 2021 07:17:43 +0200 Message-Id: <20210927051759.447305-1-its@irrelevant.dk> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.17; envelope-from=its@irrelevant.dk; helo=wnew3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , =?utf-8?q?Dan?= =?utf-8?q?iel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , qemu-block@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Markus Armbruster , Klaus Jensen , Hanna Reitz , Hannes Reinecke , Stefan Hajnoczi , Klaus Jensen , Keith Busch , Paolo Bonzini , Eric Blake Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen 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) 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