mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm, virtio-devices: Deny zero sector writes for autodetected raw images
If the disk image was autodetected to raw (not specified with image_type
= 0) then in the virtio-block subsystem generate errors for writes to
block 0 (treat as if read-only). This gives an immediate error vs using
the image implementations in the block subsystem.
Signed-off-by: Rob Bradford <rbradford@meta.com>
(cherry picked from commit b3e8e2abc5)
This commit is contained in:
@@ -2666,13 +2666,18 @@ impl DeviceManager {
|
||||
|
||||
let detected_image_type =
|
||||
detect_image_type(&mut file).map_err(DeviceManagerError::DetectImageType)?;
|
||||
let mut disable_sector0_writes = false;
|
||||
|
||||
if disk_cfg.image_type == ImageType::Unknown {
|
||||
warn!(
|
||||
"No image_type specified - detected as {detected_image_type}. \
|
||||
Configuration updated to persist type across reboots and migrations."
|
||||
);
|
||||
|
||||
if detected_image_type != ImageType::Raw {
|
||||
if detected_image_type == ImageType::Raw {
|
||||
warn!("Autodetected raw image type. Disabling sector 0 writes.");
|
||||
disable_sector0_writes = true;
|
||||
} else {
|
||||
warn!(
|
||||
"Non-raw image type detected. In the future it will be necessary \
|
||||
to specify image_type for non-raw files."
|
||||
@@ -2825,6 +2830,7 @@ impl DeviceManager {
|
||||
state_from_id(self.snapshot.as_ref(), id.as_str())
|
||||
.map_err(DeviceManagerError::RestoreGetState)?,
|
||||
queue_affinity,
|
||||
disable_sector0_writes,
|
||||
)
|
||||
.map_err(DeviceManagerError::CreateVirtioBlock)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user