mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: Remove redundant BlockBackend trait
BlockBackend predated the disk_file trait family and only carried logical_size and physical_size, which the disk backends expose through the disk_file traits DiskSize and PhysicalSize. It added no polymorphism while its Read, Write and Seek supertraits forced an unused cursor. Dropping the trait removes the dead code it was keeping alive. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
@@ -21,7 +21,7 @@ mod sparse;
|
||||
use std::alloc::{Layout, alloc_zeroed};
|
||||
use std::fmt::{self, Debug};
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::{self, Read, Seek, Write};
|
||||
use std::io::{self, Read};
|
||||
use std::os::linux::fs::MetadataExt;
|
||||
use std::os::unix::fs::FileTypeExt;
|
||||
use std::os::unix::io::{AsRawFd, RawFd};
|
||||
@@ -75,8 +75,6 @@ pub enum Error {
|
||||
InvalidOffset,
|
||||
#[error("Failure in qcow")]
|
||||
QcowError(#[source] qcow::Error),
|
||||
#[error("Failure in raw file")]
|
||||
RawFileError(#[source] io::Error),
|
||||
#[error("The requested operation does not support multiple descriptors")]
|
||||
TooManyDescriptors,
|
||||
#[error("Request contains too many segments ({0}, max {MAX_DISCARD_WRITE_ZEROES_SEG})")]
|
||||
@@ -578,17 +576,6 @@ pub fn detect_image_type(f: &mut File) -> BlockResult<ImageType> {
|
||||
Ok(image_type)
|
||||
}
|
||||
|
||||
pub trait BlockBackend: Read + Write + Seek + Send + Debug {
|
||||
/// Returns the logical disk size a guest will see.
|
||||
///
|
||||
/// For raw formats, this is equal to [`Self::physical_size`]. For file formats
|
||||
/// that wrap disk images in a container (e.g. QCOW2), this refers to the
|
||||
/// effective size that the guest will see.
|
||||
fn logical_size(&self) -> Result<u64, Error>;
|
||||
/// Returns the physical size of the underlying file.
|
||||
fn physical_size(&self) -> Result<u64, Error>;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DiskTopology {
|
||||
pub logical_block_size: u64,
|
||||
|
||||
Reference in New Issue
Block a user