vmm: disk resize infrastructure

Add basic infrastructure so resize events are
propagated to the underlying disk implementation.

On-behalf-of: SAP thomas.prescher@sap.com
Signed-off-by: Thomas Prescher <thomas.prescher@cyberus-technology.de>
This commit is contained in:
Thomas Prescher
2025-11-11 09:40:16 +01:00
committed by Rob Bradford
parent 8e52bf251b
commit 37d71fa038
7 changed files with 94 additions and 1 deletions

View File

@@ -670,6 +670,10 @@ pub enum DeviceManagerError {
/// Error adding fw_cfg to bus.
#[error("Error adding fw_cfg to bus")]
ErrorAddingFwCfgToBus(#[source] vm_device::BusError),
/// Disk resizing failed.
#[error("Disk resize error")]
DiskResize(#[source] virtio_devices::block::Error),
}
pub type DeviceManagerResult<T> = result::Result<T, DeviceManagerError>;
@@ -4901,6 +4905,18 @@ impl DeviceManager {
0
}
pub fn resize_disk(&mut self, device_id: &str, new_size: u64) -> DeviceManagerResult<()> {
for dev in &self.block_devices {
let mut disk = dev.lock().unwrap();
if disk.id() == device_id {
return disk
.resize(new_size)
.map_err(DeviceManagerError::DiskResize);
}
}
Err(DeviceManagerError::UnknownDeviceId(device_id.to_string()))
}
pub fn device_tree(&self) -> Arc<Mutex<DeviceTree>> {
self.device_tree.clone()
}