mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
committed by
Rob Bradford
parent
8e52bf251b
commit
37d71fa038
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user