All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, hreitz@redhat.com, stefanha@redhat.com,
	mst@redhat.com, devel@lists.libvirt.org, qemu-devel@nongnu.org
Subject: [PATCH v2 3/4] virtio-blk: Deprecate silent truncation of serial
Date: Fri, 30 Oct 2026 00:10:00 +0100	[thread overview]
Message-ID: <20261029231001.194240-4-kwolf@redhat.com> (raw)
In-Reply-To: <20261029231001.194240-1-kwolf@redhat.com>

Commit a8686a9b, which made serial a qdev property instead of relying on
-drive options, accidentally allowed specifying serial strings of
arbitraty length while the virtio-blk protocol can only communicate 20
characters to the guest. This means that a longer serial number on the
command line is silently truncated to 20 characters from the guest
perspective.

This is obviously bad behaviour. People are specifying longer serials in
practice and guests will see something different than what was
configured. Instead of silent truncation, this should be an error.

Deprecate the silent truncation for now as a first step towards making
it an error later.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 docs/about/deprecated.rst | 13 +++++++++++++
 hw/block/virtio-blk.c     |  6 ++++++
 2 files changed, 19 insertions(+)

diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index dab47b6ca38..0891bbc44de 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -362,6 +362,19 @@ the addition of volatile memory support, it is now necessary to distinguish
 between persistent and volatile memory backends.  As such, memdev is deprecated
 in favor of persistent-memdev.
 
+``-device virtio-blk,serial=more_than_20_characters`` (since 11.2)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The ``virtio-blk`` device has a limitation of 20 characters for the serial
+string. Accidentally, QEMU started accepting longer strings on the command line
+in version 0.15.0, but it was still silently truncated to 20 characters for
+guests.
+
+Specifying a longer serial than can be exposed to the guest is a configuration
+error and deprecated; it will become a hard error in later versions. If the
+truncation is intentional, explicitly specify the serial already in truncated
+form on the command line instead.
+
 Block device options
 ''''''''''''''''''''
 
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 3f236f22d57..eeeb405127c 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -1849,6 +1849,12 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
         return;
     }
 
+    if (conf->serial && strlen(conf->serial) > VIRTIO_BLK_ID_BYTES) {
+        warn_report("serial is longer than %d characters and will be truncated "
+                    "for the guest. This configuration is deprecated.",
+                    VIRTIO_BLK_ID_BYTES);
+    }
+
     if (!blkconf_apply_backend_options(&conf->conf,
                                        !blk_supports_write_perm(conf->conf.blk),
                                        true, errp)) {
-- 
2.56.0



  parent reply	other threads:[~2026-10-29 23:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 23:09 [PATCH v2 0/4] virtio-blk: Deprecate silent truncation of serial Kevin Wolf
2026-10-29 23:09 ` [PATCH v2 1/4] virtio-blk: Implement full NUL padding for GET_ID Kevin Wolf
2026-10-29 23:09 ` [PATCH v2 2/4] virtio-blk-test: Add a basic GET_ID test case Kevin Wolf
2026-10-30 19:30   ` Stefan Hajnoczi
2026-10-29 23:10 ` Kevin Wolf [this message]
2026-10-29 23:10 ` [PATCH v2 4/4] virtio-blk-test: Test truncated serial Kevin Wolf
2026-10-30 19:30   ` Stefan Hajnoczi
2026-10-30 19:31 ` [PATCH v2 0/4] virtio-blk: Deprecate silent truncation of serial Stefan Hajnoczi
2026-11-09 13:21 ` Christian Borntraeger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261029231001.194240-4-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=devel@lists.libvirt.org \
    --cc=hreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.