mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: qcow: Remove async_io::DiskFile impl from QcowDiskSync
QcowDiskSync now exclusively uses disk_file::DiskFile and disk_file::AsyncDiskFile. The old async_io::DiskFile impl is removed along with its unused imports (DiskFile, DiskFileError, DiskFileResult). Tests are updated to import the new traits. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
b4dad66d35
commit
0d062962ac
@@ -12,9 +12,7 @@ use std::{fmt, io, ptr, slice};
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
use vmm_sys_util::write_zeroes::{PunchHole, WriteZeroesAt};
|
||||
|
||||
use crate::async_io::{
|
||||
AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult,
|
||||
};
|
||||
use crate::async_io::{AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFileError};
|
||||
use crate::disk_file;
|
||||
use crate::error::{BlockError, BlockErrorKind, BlockResult, ErrorOp};
|
||||
use crate::qcow::metadata::{
|
||||
@@ -228,50 +226,6 @@ impl QcowDiskSync {
|
||||
}
|
||||
}
|
||||
|
||||
impl DiskFile for QcowDiskSync {
|
||||
fn logical_size(&mut self) -> DiskFileResult<u64> {
|
||||
Ok(self.metadata.virtual_size())
|
||||
}
|
||||
|
||||
fn physical_size(&mut self) -> DiskFileResult<u64> {
|
||||
self.data_raw_file
|
||||
.physical_size()
|
||||
.map_err(DiskFileError::Size)
|
||||
}
|
||||
|
||||
fn new_async_io(&self, _ring_depth: u32) -> DiskFileResult<Box<dyn AsyncIo>> {
|
||||
Ok(Box::new(QcowSync::new(
|
||||
Arc::clone(&self.metadata),
|
||||
self.data_raw_file.clone(),
|
||||
self.backing_file.as_ref().map(Arc::clone),
|
||||
self.sparse,
|
||||
)) as Box<dyn AsyncIo>)
|
||||
}
|
||||
|
||||
fn resize(&mut self, size: u64) -> DiskFileResult<()> {
|
||||
if self.backing_file.is_some() {
|
||||
return Err(DiskFileError::ResizeError(io::Error::other(
|
||||
"resize not supported with backing file",
|
||||
)));
|
||||
}
|
||||
self.metadata
|
||||
.resize(size)
|
||||
.map_err(DiskFileError::ResizeError)
|
||||
}
|
||||
|
||||
fn supports_sparse_operations(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn supports_zero_flag(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn fd(&mut self) -> BorrowedDiskFd<'_> {
|
||||
BorrowedDiskFd::new(self.data_raw_file.as_raw_fd())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for QcowDiskSync {
|
||||
fn drop(&mut self) {
|
||||
self.metadata.shutdown();
|
||||
@@ -734,7 +688,7 @@ mod unit_tests {
|
||||
use vmm_sys_util::tempfile::TempFile;
|
||||
|
||||
use super::*;
|
||||
use crate::async_io::DiskFile;
|
||||
use crate::disk_file::{AsyncDiskFile, DiskSize, Resizable};
|
||||
use crate::qcow::{BackingFileConfig, ImageType, QcowFile, RawFile};
|
||||
|
||||
fn create_disk_with_data(
|
||||
|
||||
Reference in New Issue
Block a user