Message ID | 20200703063420.2241014-18-its@irrelevant.dk |
---|---|
State | New |
Headers | show |
Series | hw/block/nvme: bump to v1.3 | expand |
On 7/3/20 8:34 AM, Klaus Jensen wrote: > From: Klaus Jensen <k.jensen@samsung.com> > > The SUBNQN field is mandatory in NVM Express 1.3. > > Signed-off-by: Klaus Jensen <k.jensen@samsung.com> > Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> > Reviewed-by: Dmitry Fomichev <dmitry.fomichev@wdc.com> > --- > hw/block/nvme.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/hw/block/nvme.c b/hw/block/nvme.c > index 8138baa6fbd8..5bbb6aa0efc3 100644 > --- a/hw/block/nvme.c > +++ b/hw/block/nvme.c > @@ -2134,6 +2134,9 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev) > id->oncs = cpu_to_le16(NVME_ONCS_WRITE_ZEROS | NVME_ONCS_TIMESTAMP | > NVME_ONCS_FEATURES); > > + pstrcpy((char *) id->subnqn, sizeof(id->subnqn), "nqn.2019-08.org.qemu:"); > + pstrcat((char *) id->subnqn, sizeof(id->subnqn), n->params.serial); What about using strpadcpy()? char *subnqn = g_strdup_printf("nqn.2019-08.org.qemu:%s", n->params.serial); strpadcpy((char *)id->subnqn, sizeof(id->subnqn), subnqn, '\0'); g_free(subnqn); > + > id->psd[0].mp = cpu_to_le16(0x9c4); > id->psd[0].enlat = cpu_to_le32(0x10); > id->psd[0].exlat = cpu_to_le32(0x4); >
On Jul 3 10:18, Philippe Mathieu-Daudé wrote: > On 7/3/20 8:34 AM, Klaus Jensen wrote: > > From: Klaus Jensen <k.jensen@samsung.com> > > > > The SUBNQN field is mandatory in NVM Express 1.3. > > > > Signed-off-by: Klaus Jensen <k.jensen@samsung.com> > > Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> > > Reviewed-by: Dmitry Fomichev <dmitry.fomichev@wdc.com> > > --- > > hw/block/nvme.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/hw/block/nvme.c b/hw/block/nvme.c > > index 8138baa6fbd8..5bbb6aa0efc3 100644 > > --- a/hw/block/nvme.c > > +++ b/hw/block/nvme.c > > @@ -2134,6 +2134,9 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev) > > id->oncs = cpu_to_le16(NVME_ONCS_WRITE_ZEROS | NVME_ONCS_TIMESTAMP | > > NVME_ONCS_FEATURES); > > > > + pstrcpy((char *) id->subnqn, sizeof(id->subnqn), "nqn.2019-08.org.qemu:"); > > + pstrcat((char *) id->subnqn, sizeof(id->subnqn), n->params.serial); > > What about using strpadcpy()? > > char *subnqn = g_strdup_printf("nqn.2019-08.org.qemu:%s", > n->params.serial); > strpadcpy((char *)id->subnqn, sizeof(id->subnqn), subnqn, '\0'); > g_free(subnqn); > Thanks, that's better. Fixed!
diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 8138baa6fbd8..5bbb6aa0efc3 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -2134,6 +2134,9 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev) id->oncs = cpu_to_le16(NVME_ONCS_WRITE_ZEROS | NVME_ONCS_TIMESTAMP | NVME_ONCS_FEATURES); + pstrcpy((char *) id->subnqn, sizeof(id->subnqn), "nqn.2019-08.org.qemu:"); + pstrcat((char *) id->subnqn, sizeof(id->subnqn), n->params.serial); + id->psd[0].mp = cpu_to_le16(0x9c4); id->psd[0].enlat = cpu_to_le32(0x10); id->psd[0].exlat = cpu_to_le32(0x4);