mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: Add disk_file module skeleton
Composable disk capability traits with DiskFile as a supertrait bundling DiskSize and Geometry. Optional capabilities are separate traits: PhysicalSize, DiskFd, SparseCapable, Resizable. AsyncDiskFile extends DiskFile with async I/O construction. Empty module with doc comment, trait definitions follow. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
297b683fcb
commit
a15bfcfee6
34
block/src/disk_file.rs
Normal file
34
block/src/disk_file.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2026 The Cloud Hypervisor Authors. All rights reserved.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
//! Composable disk capability traits for the block crate.
|
||||
//!
|
||||
//! Small traits define individual capabilities:
|
||||
//!
|
||||
//! - [`DiskSize`] - reported capacity (logical size)
|
||||
//! - [`PhysicalSize`] - host allocation size
|
||||
//! - [`DiskFd`] - backing file descriptor access
|
||||
//! - [`Geometry`] - sector/cluster geometry (default 512B)
|
||||
//! - [`SparseCapable`] - sparse and zero flag support
|
||||
//! - [`Resizable`] - online resize
|
||||
//!
|
||||
//! [`DiskFile`] is a supertrait that bundles the universal capabilities
|
||||
//! (`DiskSize` + `Geometry`). [`FullDiskFile`] adds all optional
|
||||
//! capabilities. [`AsyncDiskFile`] extends `DiskFile` with async I/O
|
||||
//! construction for virtio queue workers. [`AsyncFullDiskFile`]
|
||||
//! combines both axes.
|
||||
//!
|
||||
//! ```text
|
||||
//! DiskFile: DiskSize + Geometry + Sync
|
||||
//! / \
|
||||
//! FullDiskFile: AsyncDiskFile:
|
||||
//! DiskFile + PhysicalSize + DiskFile + Unpin
|
||||
//! DiskFd + SparseCapable + try_clone, new_async_io
|
||||
//! Resizable
|
||||
//! \ /
|
||||
//! AsyncFullDiskFile: FullDiskFile + AsyncDiskFile
|
||||
//! ```
|
||||
//!
|
||||
//! Readonly accessors take `&self`. Only [`Resizable::resize`] requires
|
||||
//! `&mut self`. Errors are returned as [`BlockResult`].
|
||||
@@ -9,6 +9,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||
|
||||
pub mod async_io;
|
||||
pub mod disk_file;
|
||||
pub mod error;
|
||||
pub mod fcntl;
|
||||
pub mod fixed_vhd;
|
||||
|
||||
Reference in New Issue
Block a user