On Jul 3 10:18, Philippe Mathieu-Daudé wrote: > On 7/3/20 8:34 AM, Klaus Jensen wrote: > > From: Klaus Jensen <k.jen...@samsung.com> > > > > The SUBNQN field is mandatory in NVM Express 1.3. > > > > Signed-off-by: Klaus Jensen <k.jen...@samsung.com> > > Reviewed-by: Maxim Levitsky <mlevi...@redhat.com> > > Reviewed-by: Dmitry Fomichev <dmitry.fomic...@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!