mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: qcow_async: impl Resizable for QcowDiskAsync
Delegates to QcowMetadata::resize. Rejects resize when a backing file is present, same as the sync backend. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
52cd45874a
commit
8c3b6cb04b
@@ -6,14 +6,14 @@
|
||||
|
||||
//! QCOW2 async disk backend.
|
||||
|
||||
use std::fmt;
|
||||
use std::fs::File;
|
||||
use std::os::fd::{AsFd, AsRawFd};
|
||||
use std::sync::Arc;
|
||||
use std::{fmt, io};
|
||||
|
||||
use crate::async_io::BorrowedDiskFd;
|
||||
use crate::async_io::{BorrowedDiskFd, DiskFileError};
|
||||
use crate::disk_file;
|
||||
use crate::error::{BlockErrorKind, BlockResult, ErrorOp};
|
||||
use crate::error::{BlockError, BlockErrorKind, BlockResult, ErrorOp};
|
||||
use crate::qcow::backing::shared_backing_from;
|
||||
use crate::qcow::metadata::{BackingRead, QcowMetadata};
|
||||
use crate::qcow::qcow_raw_file::QcowRawFile;
|
||||
@@ -101,3 +101,21 @@ impl disk_file::SparseCapable for QcowDiskAsync {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl disk_file::Resizable for QcowDiskAsync {
|
||||
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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user