Skip to content

Instantly share code, notes, and snippets.

@rwmjones
Created August 3, 2026 16:00
Show Gist options
  • Select an option

  • Save rwmjones/0b7fb1b265a620831e06b6191ee03751 to your computer and use it in GitHub Desktop.

Select an option

Save rwmjones/0b7fb1b265a620831e06b6191ee03751 to your computer and use it in GitHub Desktop.
From c2134e3162b175a5d6a5ad17c771c105bd420485 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 3 Aug 2026 16:59:57 +0100
Subject: [PATCH] device-types/blk/description.tex: Allow longer device IDs to
be returned
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
---
device-types/blk/description.tex | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/device-types/blk/description.tex b/device-types/blk/description.tex
index 3b3a4e7..2a5410a 100644
--- a/device-types/blk/description.tex
+++ b/device-types/blk/description.tex
@@ -456,8 +456,9 @@ \subsection{Device Operation}\label{sec:Device Types / Block Device / Device Ope
The type of the request is either a read (VIRTIO_BLK_T_IN), a write
(VIRTIO_BLK_T_OUT), a discard (VIRTIO_BLK_T_DISCARD), a write zeroes
-(VIRTIO_BLK_T_WRITE_ZEROES), a flush (VIRTIO_BLK_T_FLUSH), a get device ID
-string command (VIRTIO_BLK_T_GET_ID), a secure erase
+(VIRTIO_BLK_T_WRITE_ZEROES), a flush (VIRTIO_BLK_T_FLUSH), get device ID
+string (VIRTIO_BLK_T_GET_ID) and length
+(VIRTIO_BLK_GET_ID_LEN) commands, a secure erase
(VIRTIO_BLK_T_SECURE_ERASE), or a get device lifetime command
(VIRTIO_BLK_T_GET_LIFETIME).
@@ -466,6 +467,7 @@ \subsection{Device Operation}\label{sec:Device Types / Block Device / Device Ope
#define VIRTIO_BLK_T_OUT 1
#define VIRTIO_BLK_T_FLUSH 4
#define VIRTIO_BLK_T_GET_ID 8
+#define VIRTIO_BLK_T_GET_ID_LEN 9
#define VIRTIO_BLK_T_GET_LIFETIME 10
#define VIRTIO_BLK_T_DISCARD 11
#define VIRTIO_BLK_T_WRITE_ZEROES 13
@@ -515,9 +517,20 @@ \subsection{Device Operation}\label{sec:Device Types / Block Device / Device Ope
the device to discard the specified range, provided that following reads return
zeroes.
-VIRTIO_BLK_T_GET_ID requests fetch the device ID string from the device into
-\field{data}. The device ID string is a NUL-padded ASCII string up to 20 bytes
-long. If the string is 20 bytes long then there is no NUL terminator.
+
+VIRTIO_BLK_T_GET_ID and VIRTIO_BLK_T_GET_ID_LEN are used together to
+request the device ID string (aka serial number).
+
+VIRTIO_BLK_T_GET_ID_LEN should be called first. It returns the length
+of the device ID string as a single le16 number (LEN). If successful,
+VIRTIO_BLK_T_GET_ID returns the device ID string into \field{data},
+returning exactly LEN bytes. The string is not NUL-padded or
+NUL-terminated in this case.
+
+If VIRTIO_BLK_T_GET_ID_LEN is unimplemented then VIRTIO_BLK_T_GET_ID
+behaves in a legacy way. The device ID string is a NUL-padded ASCII
+string up to 20 bytes long. If the string is 20 bytes long then there
+is no NUL terminator.
The \field{data} used for VIRTIO_BLK_T_GET_LIFETIME requests is populated
by the device, and is of the form
--
2.55.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment