mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: qcow_sync: impl Resizable for QcowDiskSync
Add ErrorOp::Resize variant and implement the Resizable trait. Resize is rejected when a backing file is present. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
554562fef2
commit
f35bec19e8
@@ -308,6 +308,24 @@ impl disk_file::SparseCapable for QcowDiskSync {
|
||||
}
|
||||
}
|
||||
|
||||
impl disk_file::Resizable for QcowDiskSync {
|
||||
fn resize(&mut self, size: u64) -> BlockResult<()> {
|
||||
if self.backing_file.is_some() {
|
||||
return Err(BlockError::new(
|
||||
BlockErrorKind::UnsupportedFeature,
|
||||
DiskFileError::ResizeError(io::Error::other(
|
||||
"resize not supported with backing file",
|
||||
)),
|
||||
)
|
||||
.with_op(ErrorOp::Resize));
|
||||
}
|
||||
self.metadata.resize(size).map_err(|e| {
|
||||
BlockError::new(BlockErrorKind::Io, DiskFileError::ResizeError(e))
|
||||
.with_op(ErrorOp::Resize)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub struct QcowSync {
|
||||
metadata: Arc<QcowMetadata>,
|
||||
data_file: QcowRawFile,
|
||||
|
||||
Reference in New Issue
Block a user