Am 29.10.2026 um 13:51 hat Stefan Hajnoczi geschrieben:
> 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.

Do we know of any such management tools, or is the concern just out of an
abundance of caution?

It sounds fundamentally wrong to me to use the serial as opposed to the
qdev id to identify devices.

> Let's hold off on this change until the deprecation grace period
> finishes.

I can drop the patch for a v2 of this series (or just apply it without
this patch if no other changes are necessary) as the value of the qdev
property should be the only real effect at the moment.

However, with the work that actually enables longer serials, having an
internal state that doesn't match what the guest sees feels rather error
prone. So I'd be happy to defer the change of the serial in the internal
state to the 12.0 cycle, but probably not until after the deprecation
period.

Kevin

> > 
> > 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
> > 
> 

Reply via email to