block: add DiskFile::physical_size()

This is a pre-requisite for the bug fix in the following commit.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster
2025-12-12 09:07:44 +01:00
committed by Rob Bradford
parent 53092359b4
commit 603b5e862c
14 changed files with 90 additions and 2 deletions

View File

@@ -836,10 +836,12 @@ pub fn detect_image_type(f: &mut File) -> std::io::Result<ImageType> {
pub trait BlockBackend: Read + Write + Seek + Send + Debug {
/// Returns the logical disk size a guest will see.
///
/// For raw formats, this is equal to the physical_size. For file formats
/// 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)]