[PATCH] hw/nvme: add `model` parameter

Avi Kivity posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260302142831.1269291-1-avi@scylladb.com
Maintainers: Keith Busch <kbusch@kernel.org>, Klaus Jensen <its@irrelevant.dk>, Jesper Devantier <foss@defmacro.it>, Pierrick Bouvier <pierrick.bouvier@linaro.org>
docs/system/devices/nvme.rst | 8 ++++++++
hw/nvme/ctrl.c               | 4 +++-
hw/nvme/nvme.h               | 1 +
3 files changed, 12 insertions(+), 1 deletion(-)
[PATCH] hw/nvme: add `model` parameter
Posted by Avi Kivity 1 month, 1 week ago
Add a `model` parameter, readable with nvme-cli. This allows
impersonating other disk manufacturers or hypervisors, similar
to the the -smbios option.

Signed-off-by: Avi Kivity <avi@scylladb.com>
---

Disclosure: prepared with AI assistance. I believe it to be of good
quality.

 docs/system/devices/nvme.rst | 8 ++++++++
 hw/nvme/ctrl.c               | 4 +++-
 hw/nvme/nvme.h               | 1 +
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/docs/system/devices/nvme.rst b/docs/system/devices/nvme.rst
index 6509b35fcb..1d4dd66d65 100644
--- a/docs/system/devices/nvme.rst
+++ b/docs/system/devices/nvme.rst
@@ -58,10 +58,18 @@ parameters.
   sits on top of NVMe. It describes additional commands and NVMe behaviors
   specific for the Datacenter. When this option is ``on`` OCP features such as
   the SMART / Health information extended log become available in the
   controller. We emulate version 5 of this log page.
 
+``model`` (default: ``QEMU NVMe Ctrl``)
+  Set the model name reported in the Identify Controller data structure (field
+  ``MN``). The value is visible to the guest as
+  ``/sys/class/nvme/<name>/model``. This is useful for emulating specific
+  NVMe devices; for example, setting ``model=Amazon Elastic Block Store``
+  allows guest software to distinguish emulated EBS volumes from instance
+  storage.
+
 Additional Namespaces
 ---------------------
 
 In the simplest possible invocation sketched above, the device only support a
 single namespace with the namespace identifier ``1``. To support multiple
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index cc4593cd42..2d1fb7a209 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -9092,11 +9092,12 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
     memcpy(n->cse.iocs.zoned, nvme_cse_iocs_zoned_default,
            sizeof(n->cse.iocs.zoned));
 
     id->vid = cpu_to_le16(pci_get_word(pci_conf + PCI_VENDOR_ID));
     id->ssvid = cpu_to_le16(pci_get_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID));
-    strpadcpy((char *)id->mn, sizeof(id->mn), "QEMU NVMe Ctrl", ' ');
+    strpadcpy((char *)id->mn, sizeof(id->mn),
+              n->params.model ? n->params.model : "QEMU NVMe Ctrl", ' ');
     strpadcpy((char *)id->fr, sizeof(id->fr), QEMU_VERSION, ' ');
     strpadcpy((char *)id->sn, sizeof(id->sn), n->params.serial, ' ');
 
     id->cntlid = cpu_to_le16(n->cntlid);
 
@@ -9372,10 +9373,11 @@ static const Property nvme_props[] = {
     DEFINE_PROP_LINK("pmrdev", NvmeCtrl, pmr.dev, TYPE_MEMORY_BACKEND,
                      HostMemoryBackend *),
     DEFINE_PROP_LINK("subsys", NvmeCtrl, subsys, TYPE_NVME_SUBSYS,
                      NvmeSubsystem *),
     DEFINE_PROP_STRING("serial", NvmeCtrl, params.serial),
+    DEFINE_PROP_STRING("model", NvmeCtrl, params.model),
     DEFINE_PROP_UINT32("cmb_size_mb", NvmeCtrl, params.cmb_size_mb, 0),
     DEFINE_PROP_UINT32("num_queues", NvmeCtrl, params.num_queues, 0),
     DEFINE_PROP_UINT32("max_ioqpairs", NvmeCtrl, params.max_ioqpairs, 64),
     DEFINE_PROP_UINT16("msix_qsize", NvmeCtrl, params.msix_qsize, 65),
     DEFINE_PROP_UINT8("aerl", NvmeCtrl, params.aerl, 3),
diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index d66f7dc82d..ebf1fcfdcd 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -540,10 +540,11 @@ typedef struct NvmeCQueue {
 #define NVME(obj) \
         OBJECT_CHECK(NvmeCtrl, (obj), TYPE_NVME)
 
 typedef struct NvmeParams {
     char     *serial;
+    char     *model;
     uint32_t num_queues; /* deprecated since 5.1 */
     uint32_t max_ioqpairs;
     uint16_t msix_qsize;
     uint16_t mqes;
     uint32_t cmb_size_mb;
-- 
2.53.0
Re: [PATCH] hw/nvme: add `model` parameter
Posted by Daniel P. Berrangé 1 month, 1 week ago
On Mon, Mar 02, 2026 at 04:27:48PM +0200, Avi Kivity wrote:
> Add a `model` parameter, readable with nvme-cli. This allows
> impersonating other disk manufacturers or hypervisors, similar
> to the the -smbios option.
> 
> Signed-off-by: Avi Kivity <avi@scylladb.com>
> ---
> 
> Disclosure: prepared with AI assistance. I believe it to be of good
> quality.

Can you clarify how AI was involved, as QEMU's policy is to decline
any contributions where AI was involing in an authoring role:

  https://www.qemu.org/docs/master/devel/code-provenance.html#use-of-ai-generated-content

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
Re: [PATCH] hw/nvme: add `model` parameter
Posted by Avi Kivity 1 month, 1 week ago
On Mon, Mar 2, 2026 at 4:39 PM Daniel P. Berrangé <berrange@redhat.com>
wrote:

> On Mon, Mar 02, 2026 at 04:27:48PM +0200, Avi Kivity wrote:
> > Add a `model` parameter, readable with nvme-cli. This allows
> > impersonating other disk manufacturers or hypervisors, similar
> > to the the -smbios option.
> >
> > Signed-off-by: Avi Kivity <avi@scylladb.com>
> > ---
> >
> > Disclosure: prepared with AI assistance. I believe it to be of good
> > quality.
>
> Can you clarify how AI was involved,


I asked an LLM (Claude) to add a model parameter to the nvme code, which it
did, then I asked it to documented it, which it also did.


> as QEMU's policy is to decline
> any contributions where AI was involing in an authoring role:
>

Very unfortunate. It would have taken me an hour or two to re-orient myself
in the code base, for something that took me a couple of minutes with AI.



>
>
> https://www.qemu.org/docs/master/devel/code-provenance.html#use-of-ai-generated-content
>
> With regards,
> Daniel
> --
> |: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
> |: https://libvirt.org          ~~          https://entangle-photo.org :|
> |: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
>
>
Re: [PATCH] hw/nvme: add `model` parameter
Posted by Avi Kivity 1 month, 1 week ago
On Mon, Mar 2, 2026 at 4:50 PM Avi Kivity <avi@scylladb.com> wrote:

>
>
> On Mon, Mar 2, 2026 at 4:39 PM Daniel P. Berrangé <berrange@redhat.com>
> wrote:
>
>> On Mon, Mar 02, 2026 at 04:27:48PM +0200, Avi Kivity wrote:
>> > Add a `model` parameter, readable with nvme-cli. This allows
>> > impersonating other disk manufacturers or hypervisors, similar
>> > to the the -smbios option.
>> >
>> > Signed-off-by: Avi Kivity <avi@scylladb.com>
>> > ---
>> >
>> > Disclosure: prepared with AI assistance. I believe it to be of good
>> > quality.
>>
>> Can you clarify how AI was involved,
>
>
> I asked an LLM (Claude) to add a model parameter to the nvme code, which
> it did, then I asked it to documented it, which it also did.
>
>
>> as QEMU's policy is to decline
>> any contributions where AI was involing in an authoring role:
>>
>
> Very unfortunate. It would have taken me an hour or two to re-orient
> myself in the code base, for something that took me a couple of minutes
> with AI.
>

So what's the verdict?

FWIW I think the probability of AI copying these few lines from some
non-GPL project is zero.
Re: [PATCH] hw/nvme: add `model` parameter
Posted by Klaus Jensen 1 month, 1 week ago
On Mar  5 13:11, Avi Kivity wrote:
> On Mon, Mar 2, 2026 at 4:50 PM Avi Kivity <avi@scylladb.com> wrote:
> 
> >
> >
> > On Mon, Mar 2, 2026 at 4:39 PM Daniel P. Berrangé <berrange@redhat.com>
> > wrote:
> >
> >> On Mon, Mar 02, 2026 at 04:27:48PM +0200, Avi Kivity wrote:
> >> > Add a `model` parameter, readable with nvme-cli. This allows
> >> > impersonating other disk manufacturers or hypervisors, similar
> >> > to the the -smbios option.
> >> >
> >> > Signed-off-by: Avi Kivity <avi@scylladb.com>
> >> > ---
> >> >
> >> > Disclosure: prepared with AI assistance. I believe it to be of good
> >> > quality.
> >>
> >> Can you clarify how AI was involved,
> >
> >
> > I asked an LLM (Claude) to add a model parameter to the nvme code, which
> > it did, then I asked it to documented it, which it also did.
> >
> >
> >> as QEMU's policy is to decline
> >> any contributions where AI was involing in an authoring role:
> >>
> >
> > Very unfortunate. It would have taken me an hour or two to re-orient
> > myself in the code base, for something that took me a couple of minutes
> > with AI.
> >
> 
> So what's the verdict?
> 
> FWIW I think the probability of AI copying these few lines from some
> non-GPL project is zero.

As maintainer I don't have a problem taking this patch, but I'm not sure
how to deal with the policy in this instance.

Daniel, please advise if I can take this. I'd have written the patch
like this myself.
Re: [PATCH] hw/nvme: add `model` parameter
Posted by Daniel P. Berrangé 1 month ago
On Thu, Mar 05, 2026 at 01:47:45PM +0100, Klaus Jensen wrote:
> On Mar  5 13:11, Avi Kivity wrote:
> > On Mon, Mar 2, 2026 at 4:50 PM Avi Kivity <avi@scylladb.com> wrote:
> > 
> > >
> > >
> > > On Mon, Mar 2, 2026 at 4:39 PM Daniel P. Berrangé <berrange@redhat.com>
> > > wrote:
> > >
> > >> On Mon, Mar 02, 2026 at 04:27:48PM +0200, Avi Kivity wrote:
> > >> > Add a `model` parameter, readable with nvme-cli. This allows
> > >> > impersonating other disk manufacturers or hypervisors, similar
> > >> > to the the -smbios option.
> > >> >
> > >> > Signed-off-by: Avi Kivity <avi@scylladb.com>
> > >> > ---
> > >> >
> > >> > Disclosure: prepared with AI assistance. I believe it to be of good
> > >> > quality.
> > >>
> > >> Can you clarify how AI was involved,
> > >
> > >
> > > I asked an LLM (Claude) to add a model parameter to the nvme code, which
> > > it did, then I asked it to documented it, which it also did.
> > >
> > >
> > >> as QEMU's policy is to decline
> > >> any contributions where AI was involing in an authoring role:
> > >>
> > >
> > > Very unfortunate. It would have taken me an hour or two to re-orient
> > > myself in the code base, for something that took me a couple of minutes
> > > with AI.
> > >
> > 
> > So what's the verdict?
> > 
> > FWIW I think the probability of AI copying these few lines from some
> > non-GPL project is zero.
> 
> As maintainer I don't have a problem taking this patch, but I'm not sure
> how to deal with the policy in this instance.

When introducing the policy we had debated whether to allow so called
"trivial" patches where one might argue the copyrightability concerns
are negligible, but could not come to agreement on that matter so left
it as strict policy.

> Daniel, please advise if I can take this. I'd have written the patch
> like this myself.

To avoid having to exhaust time debating this, I've wrote new
patches myself without direct reference to Avi's proposal, which
do the equivalent thing, plus some more on top.

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|