vmm: Disable sector 0 writes for autodetected VHD images

When no image_type is specified, sector 0 writes are disabled as a
safety measure for autodetected raw images. Extend this protection
to autodetected fixed VHD images, which carry metadata in the last
sector and are equally susceptible to accidental overwrites of the
first sector when the format is not explicitly acknowledged.

Update the corresponding warning in the virtio block worker to be
format agnostic.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-05-14 18:13:23 +02:00
committed by Bo Chen
parent 1ad9920713
commit 9d487a8abc
2 changed files with 7 additions and 5 deletions

View File

@@ -193,9 +193,7 @@ impl BlockEpollHandler {
}
if request_type == RequestType::Out && disable_sector0_writes && request.sector() == 0 {
warn!(
"Attempting to write to sector 0 on a raw disk without specifying image_type=raw"
);
warn!("Attempting to write to sector 0 on a disk without specifying image_type");
return Err(ExecuteError::ReadOnly);
}

View File

@@ -2734,8 +2734,12 @@ impl DeviceManager {
Configuration updated to persist type across reboots and migrations."
);
if detected_image_type == ImageType::Raw {
warn!("Autodetected raw image type. Disabling sector 0 writes.");
if detected_image_type == ImageType::Raw
|| detected_image_type == ImageType::FixedVhd
{
warn!(
"Autodetected {detected_image_type} image type. Disabling sector 0 writes."
);
disable_sector0_writes = true;
} else {
warn!(