ch-remote: support live disk resizing

Support disk resizing via ch-remote and REST api.

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-10 12:49:17 +01:00
committed by Rob Bradford
parent aac240d076
commit 5fb078305a
4 changed files with 94 additions and 3 deletions

View File

@@ -134,6 +134,10 @@ pub enum ApiError {
#[error("The VM could not be resized")]
VmResize(#[source] VmError),
/// The disk could not be resized.
#[error("The disk could not be resized")]
VmResizeDisk(#[source] VmError),
/// The memory zone could not be resized.
#[error("The memory zone could not be resized")]
VmResizeZone(#[source] VmError),
@@ -223,6 +227,12 @@ pub struct VmResizeData {
pub desired_balloon: Option<u64>,
}
#[derive(Clone, Deserialize, Serialize, Default, Debug)]
pub struct VmResizeDiskData {
pub id: String,
pub desired_size: u64,
}
#[derive(Clone, Deserialize, Serialize, Default, Debug)]
pub struct VmResizeZoneData {
pub id: String,
@@ -1139,6 +1149,41 @@ impl ApiAction for VmResize {
}
}
pub struct VmResizeDisk;
impl ApiAction for VmResizeDisk {
type RequestBody = VmResizeDiskData;
type ResponseBody = Option<Body>;
fn request(
&self,
resize_disk_data: Self::RequestBody,
response_sender: Sender<ApiResponse>,
) -> ApiRequest {
Box::new(move |vmm| {
let response = vmm
.vm_resize_disk(resize_disk_data.id, resize_disk_data.desired_size)
.map_err(ApiError::VmResizeDisk)
.map(|_| ApiResponsePayload::Empty);
response_sender
.send(response)
.map_err(VmmError::ApiResponseSend)?;
Ok(false)
})
}
fn send(
&self,
api_evt: EventFd,
api_sender: Sender<ApiRequest>,
data: Self::RequestBody,
) -> ApiResult<Self::ResponseBody> {
get_response_body(self, api_evt, api_sender, data)
}
}
pub struct VmResizeZone;
impl ApiAction for VmResizeZone {