virtio-blk: Deprecate silent truncation of serial
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>
Message-ID: <20261029231001.194240-4-kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
1 parent
b5fabdc072
commit
6ea787b258
2 files changed
+19
No files matched your search
@@ -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
|
||||
''''''''''''''''''''
|
||||
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in new issue
Block a user