> -----Original Message----- > From: Qemu-devel <qemu-devel- > bounces+dmitry.fomichev=wdc....@nongnu.org> On Behalf Of Klaus > Jensen > Sent: Thursday, October 1, 2020 5:51 PM > To: qemu-de...@nongnu.org > Cc: Kevin Wolf <kw...@redhat.com>; qemu-block@nongnu.org; Klaus Jensen > <k.jen...@samsung.com>; Max Reitz <mre...@redhat.com>; Klaus Jensen > <i...@irrelevant.dk>; Keith Busch <kbu...@kernel.org> > Subject: [PATCH] hw/block/nvme: update nsid when registered > > From: Klaus Jensen <k.jen...@samsung.com> > > If the user does not specify an nsid parameter on the nvme-ns device, > nvme_register_namespace will find the first free namespace id and assign > that. > > This fix makes sure the assigned id is saved. > > Signed-off-by: Klaus Jensen <k.jen...@samsung.com>
Yep, this makes autogenerated NSIDs work. Reviewed-by: Dmitry Fomichev <dmitry.fomic...@wdc.com> > --- > hw/block/nvme.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/block/nvme.c b/hw/block/nvme.c > index da8344f196a8..bb1ee009cd31 100644 > --- a/hw/block/nvme.c > +++ b/hw/block/nvme.c > @@ -2583,7 +2583,7 @@ int nvme_register_namespace(NvmeCtrl *n, > NvmeNamespace *ns, Error **errp) > for (int i = 1; i <= n->num_namespaces; i++) { > NvmeNamespace *ns = nvme_ns(n, i); > if (!ns) { > - nsid = i; > + nsid = ns->params.nsid = i; > break; > } > } > -- > 2.28.0 >