Skip to contentSkip to conversation

hw/nvme: add `model` parameter

PATCH In review Avi Kivity 3 participants 6 messages Mar 2 – Mar 6

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 hw/nvme: add `model` parameter

Add a model parameter, readable with nvme-cli. This allows impersonating other disk manufacturers or hypervisors, similar to the the -smbios option.

---

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(-)
docs/system/devices/nvme.rst +8 -0
index 6509b35fcb..1d4dd66d65 100644
@@ -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
hw/nvme/ctrl.c +3 -1
index cc4593cd42..2d1fb7a209 100644
@@ -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),
hw/nvme/nvme.h +1 -0
index d66f7dc82d..ebf1fcfdcd 100644
@@ -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;
Signature · 1 line
2.53.0
#1 lore raw
Quoted 9 lines · Avi Kivity

Add a model parameter, readable with nvme-cli. This allows impersonating other disk manufacturers or hypervisors, similar to the the -smbios option.

---

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

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
author
#2 lore raw
Quoted 5 lines · Daniel P. Berrangé
Quoted 4 lines · Avi Kivity

Add a model parameter, readable with nvme-cli. This allows impersonating other disk manufacturers or hypervisors, similar to the the -smbios option.

Quoted 7 lines
Quoted 5 lines

---

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.

Quoted 3 lines

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.

Quoted 12 lines

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 :|
author
#3 lore raw
Quoted 23 lines · Avi Kivity
Quoted 5 lines · Daniel P. Berrangé
Quoted 4 lines · Avi Kivity

Add a model parameter, readable with nvme-cli. This allows impersonating other disk manufacturers or hypervisors, similar to the the -smbios option.

Quoted 7 lines
Quoted 5 lines

---

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.

Quoted 8 lines
Quoted 3 lines

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.

#4 lore raw
Quoted 34 lines · Avi Kivity
Quoted 23 lines · Avi Kivity
Quoted 5 lines · Daniel P. Berrangé
Quoted 4 lines · Avi Kivity

Add a model parameter, readable with nvme-cli. This allows impersonating other disk manufacturers or hypervisors, similar to the the -smbios option.

Quoted 7 lines
Quoted 5 lines

---

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.

Quoted 8 lines
Quoted 3 lines

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.

Quoted 4 lines

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.

#5 lore raw
Quoted 35 lines · Klaus Jensen
Quoted 34 lines · Avi Kivity
Quoted 31 lines · Avi Kivity
Quoted 5 lines · Daniel P. Berrangé
Quoted 4 lines · Avi Kivity

Add a model parameter, readable with nvme-cli. This allows impersonating other disk manufacturers or hypervisors, similar to the the -smbios option.

Quoted 7 lines
Quoted 5 lines

---

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.

Quoted 3 lines

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.

Quoted 7 lines
Quoted 4 lines

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.

Quoted 2 lines

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

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|