On Thu, Oct 29, 2026 at 12:23:59AM +0100, Kevin Wolf wrote: > If the guest can only see the first 20 characters of the serial, we > shouldn't pretend to have a longer string in the 'serial' qdev property > (which is visible through things like QOM or 'info qtree'). > > Truncate the serial already in the internal state of the device to make > sure we don't mix both versions anywhere.
This is a user-visible change that can break software relying on QEMU's serial string output. For example, imagine QEMU is launched with a serial string that is the UUID 22382676-e635-4dca-a1db-0eaf2e2e192a. Later on, a script fetches the serial from QEMU monitor output and uses it as the volume identifier in a distributed storage system (e.g. to fetch volume statistics for the guest's disk). That script will now break because QEMU no longer retains the full string. Let's hold off on this change until the deprecation grace period finishes. > > Signed-off-by: Kevin Wolf <[email protected]> > --- > hw/block/virtio-blk.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c > index eeeb405127c..cecd08a2f2e 100644 > --- a/hw/block/virtio-blk.c > +++ b/hw/block/virtio-blk.c > @@ -1850,9 +1850,15 @@ static void virtio_blk_device_realize(DeviceState > *dev, Error **errp) > } > > if (conf->serial && strlen(conf->serial) > VIRTIO_BLK_ID_BYTES) { > + char *truncated; > + > warn_report("serial is longer than %d characters and will be > truncated " > "for the guest. This configuration is deprecated.", > VIRTIO_BLK_ID_BYTES); > + > + truncated = g_strndup(conf->serial, VIRTIO_BLK_ID_BYTES); > + g_free(conf->serial); > + conf->serial = truncated; > } > > if (!blkconf_apply_backend_options(&conf->conf, > -- > 2.56.0 >
