mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: disk_file: Add DiskFd trait
Backing file descriptor access for disk images backed by a file. Returns a BorrowedDiskFd that wraps the raw fd with lifetime tracking. Not available for network or memory backed disk formats. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
2df731b8d3
commit
2fa877e087
@@ -36,6 +36,7 @@
|
||||
use std::fmt::Debug;
|
||||
|
||||
use crate::BlockResult;
|
||||
use crate::async_io::BorrowedDiskFd;
|
||||
|
||||
/// Reported capacity of a disk image.
|
||||
pub trait DiskSize: Send + Debug {
|
||||
@@ -48,3 +49,9 @@ pub trait PhysicalSize: Send + Debug {
|
||||
/// Actual bytes occupied on the host filesystem.
|
||||
fn physical_size(&self) -> BlockResult<u64>;
|
||||
}
|
||||
|
||||
/// Backing file descriptor access for disk images backed by a file.
|
||||
pub trait DiskFd: Send + Debug {
|
||||
/// Borrows the underlying file descriptor.
|
||||
fn fd(&self) -> BorrowedDiskFd<'_>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user