All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rjones@redhat.com>
To: virtio-comment@lists.linux.dev
Subject: [PATCH 0/1] [PATCH] device-types/blk/description.tex: Allow longer device IDs to be returned
Date: Sun,  6 Sep 2026 15:54:43 +0100	[thread overview]
Message-ID: <20260906145444.127570-1-rjones@redhat.com> (raw)

This is a draft proposal to allow virtio-blk devices to have longer
device ID strings (aka serial numbers).

On Linux the serial number of a disk appears under
/sys/block/vda/serial and is used by udev to generate symlinks in
/dev/disk/by-id/.  The serial should be logically attached to a disk
image, and should not change as the disk moves around, and the
symlinks in /dev/disk/by-id/ should similarly be long lived and
permanently refer to a specific disk.

Currently virtio-blk limits the device ID string to 20 ASCII
characters.  Other buses, especially SCSI-based ones like virtio-scsi
and VMware's pvscsi, support much longer serials.  VMware (pvscsi)
calls the serial number a UUID and encodes it through SCSI VPD 0x83 as
"NAA Registered Extended" using 128 bits which Linux prints as a 32
character UUID (without dashes).  virtio-scsi supports a wider variety
of formats, up to very long serials.

This causes problems when the backing device of a disk is changed from
other types to virtio-blk.  Our specific case is when converting
guests from VMware (using pvscsi) to qemu (using virtio-blk), but a
similar thing would happen when converting between virtio-scsi and
virtio-blk.  In both cases a long serial is truncated to 20 bytes.
This causes /dev/disk/by-id/ paths inside the guest to change, meaning
that configuration files and software expecting these paths to never
change will break.

Another major concern is to prevent existing guests from breaking when
long serials are introduced.  In particular, qemu currently silently
truncates the serial parameter to 20 characters, but higher level
software (libvirt, KubeVirt) passes in the full length serial.  The
danger here is that upgrading the hypervisor + driver in a guest would
cause the longer serial to suddenly be used, breaking the guest.  Or
in another scenario, a guest template that uses the older driver would
see the truncated serial even if a new hypervisor is used, but
upgrading the driver inside the guest later would change to use the
longer serial.

Therefore this patch:

 - Leaves the old request VIRTIO_BLK_T_GET_ID alone.  Old drivers can
   continue to use this.  The existing (truncation) behaviour is
   documented.

 - Introduces a new call VIRTIO_BLK_T_GET_LONG_ID to read the full
   serial, up to 247 bytes long.  This is always NUL-terminated and
   passed through a buffer which is always 248 bytes long.

 - Advises driver writers that they should allow guests to opt in to
   longer serial support, while leaving it up to drivers / guests to
   decide what to do based on their situation.

I have written working qemu and Linux kernel patches that implement this:

https://gitlab.com/rwmjones/qemu/-/commits/2026-virtio-blk-long-id?ref_type=heads
https://github.com/rwmjones/linux/commits/2026-virtio-blk-long-id/

Rich.

Richard W.M. Jones (1):
  device-types/blk/description.tex: Allow longer device IDs to be
    returned

 device-types/blk/description.tex | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

-- 
2.55.0


             reply	other threads:[~2026-09-06 14:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06 14:54 Richard W.M. Jones [this message]
2026-09-06 14:54 ` [PATCH 1/1] device-types/blk/description.tex: Allow longer device IDs to be returned Richard W.M. Jones
2026-09-06 15:13   ` Michael S. Tsirkin
2026-09-06 16:06     ` Richard W.M. Jones
2026-09-07  7:33       ` Michael S. Tsirkin
2026-09-07  7:56   ` Michael S. Tsirkin
2026-09-07 14:02     ` Richard W.M. Jones
2026-09-07 19:27       ` Michael S. Tsirkin
2026-09-08  9:35         ` Richard W.M. Jones
2026-09-08 10:06           ` Michael S. Tsirkin
2026-09-08 10:43             ` Richard W.M. Jones
2026-09-08 10:57               ` Michael S. Tsirkin

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=20260906145444.127570-1-rjones@redhat.com \
    --to=rjones@redhat.com \
    --cc=virtio-comment@lists.linux.dev \
    /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.