mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: vhd: Flatten internal and worker modules
Remove the internal and worker submodule layers from the VHD format directory. The footer and fixed parsers move up as footer.rs and fixed.rs, and the backends move up as engine_sync.rs and engine_uring.rs. Both internal/mod.rs and worker/mod.rs held only module declarations and are dropped. Assisted-by: Claude:Opus-4.8 Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
ecf72ba787
commit
6e0c39964a
@@ -12,13 +12,13 @@ use crate::AlignedFile;
|
||||
use crate::async_io::{AsyncIo, AsyncIoCompletion, AsyncIoError, AsyncIoOperation, AsyncIoResult};
|
||||
use crate::formats::raw::engine_sync::RawSync;
|
||||
|
||||
pub struct FixedVhdSync {
|
||||
pub(super) struct FixedVhdSync {
|
||||
raw_file_sync: RawSync,
|
||||
size: u64,
|
||||
}
|
||||
|
||||
impl FixedVhdSync {
|
||||
pub fn new(raw_file: AlignedFile, size: u64) -> Self {
|
||||
pub(super) fn new(raw_file: AlignedFile, size: u64) -> Self {
|
||||
FixedVhdSync {
|
||||
raw_file_sync: RawSync::new(raw_file),
|
||||
size,
|
||||
@@ -13,13 +13,13 @@ use crate::async_io::{AsyncIo, AsyncIoCompletion, AsyncIoError, AsyncIoOperation
|
||||
use crate::error::BlockResult;
|
||||
use crate::formats::raw::engine_uring::RawAsync;
|
||||
|
||||
pub struct FixedVhdAsync {
|
||||
pub(super) struct FixedVhdAsync {
|
||||
raw_file_async: RawAsync,
|
||||
size: u64,
|
||||
}
|
||||
|
||||
impl FixedVhdAsync {
|
||||
pub fn new(raw_file: AlignedFile, ring_depth: u32, size: u64) -> BlockResult<Self> {
|
||||
pub(super) fn new(raw_file: AlignedFile, ring_depth: u32, size: u64) -> BlockResult<Self> {
|
||||
let raw_file_async = RawAsync::new(raw_file, ring_depth)?;
|
||||
|
||||
Ok(FixedVhdAsync {
|
||||
@@ -9,13 +9,13 @@ use std::os::unix::io::{AsRawFd, RawFd};
|
||||
use super::footer::VhdFooter;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FixedVhd {
|
||||
pub(super) struct FixedVhd {
|
||||
file: File,
|
||||
size: u64,
|
||||
}
|
||||
|
||||
impl FixedVhd {
|
||||
pub fn new(mut file: File) -> io::Result<Self> {
|
||||
pub(super) fn new(mut file: File) -> io::Result<Self> {
|
||||
let footer = VhdFooter::new(&mut file)?;
|
||||
|
||||
Ok(Self {
|
||||
@@ -13,7 +13,7 @@ use crate::{AlignedFile, query_device_size};
|
||||
// spec completeness and exercised only by unit tests.
|
||||
#[derive(Clone, Copy)]
|
||||
#[cfg_attr(not(test), expect(dead_code))]
|
||||
pub struct VhdFooter {
|
||||
pub(super) struct VhdFooter {
|
||||
cookie: u64,
|
||||
features: u32,
|
||||
file_format_version: u32,
|
||||
@@ -32,7 +32,7 @@ pub struct VhdFooter {
|
||||
}
|
||||
|
||||
impl VhdFooter {
|
||||
pub fn new(file: &mut File) -> io::Result<VhdFooter> {
|
||||
pub(super) fn new(file: &mut File) -> io::Result<VhdFooter> {
|
||||
let aligned = AlignedFile::new(file.try_clone()?, true);
|
||||
let size = query_device_size(file)?.0;
|
||||
let footer_offset = size.checked_sub(512).ok_or_else(|| {
|
||||
@@ -60,17 +60,17 @@ impl VhdFooter {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn cookie(&self) -> u64 {
|
||||
pub(super) fn cookie(&self) -> u64 {
|
||||
self.cookie
|
||||
}
|
||||
#[cfg(test)]
|
||||
pub fn features(&self) -> u32 {
|
||||
self.features
|
||||
}
|
||||
pub fn file_format_version(&self) -> u32 {
|
||||
pub(super) fn file_format_version(&self) -> u32 {
|
||||
self.file_format_version
|
||||
}
|
||||
pub fn data_offset(&self) -> u64 {
|
||||
pub(super) fn data_offset(&self) -> u64 {
|
||||
self.data_offset
|
||||
}
|
||||
#[cfg(test)]
|
||||
@@ -93,14 +93,14 @@ impl VhdFooter {
|
||||
pub fn original_size(&self) -> u64 {
|
||||
self.original_size
|
||||
}
|
||||
pub fn current_size(&self) -> u64 {
|
||||
pub(super) fn current_size(&self) -> u64 {
|
||||
self.current_size
|
||||
}
|
||||
#[cfg(test)]
|
||||
pub fn disk_geometry(&self) -> u32 {
|
||||
self.disk_geometry
|
||||
}
|
||||
pub fn disk_type(&self) -> u32 {
|
||||
pub(super) fn disk_type(&self) -> u32 {
|
||||
self.disk_type
|
||||
}
|
||||
#[cfg(test)]
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright 2026 The Cloud Hypervisor Authors. All rights reserved.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
//! VHD format parsing and data structures.
|
||||
//!
|
||||
//! Contains the footer parser and the low level fixed VHD
|
||||
//! block backend.
|
||||
|
||||
pub(crate) mod fixed;
|
||||
pub(crate) mod footer;
|
||||
@@ -9,20 +9,23 @@
|
||||
//! Provides [`VhdDisk`], the `DiskFile` wrapper for fixed size VHD
|
||||
//! images.
|
||||
|
||||
pub(crate) mod internal;
|
||||
pub(crate) mod worker;
|
||||
mod engine_sync;
|
||||
#[cfg(feature = "io_uring")]
|
||||
mod engine_uring;
|
||||
mod fixed;
|
||||
mod footer;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
|
||||
pub use internal::footer::is_fixed_vhd;
|
||||
pub use footer::is_fixed_vhd;
|
||||
use log::warn;
|
||||
|
||||
use self::internal::fixed::FixedVhd;
|
||||
use self::engine_sync::FixedVhdSync;
|
||||
#[cfg(feature = "io_uring")]
|
||||
use self::worker::async_uring::FixedVhdAsync;
|
||||
use self::worker::sync::FixedVhdSync;
|
||||
use self::engine_uring::FixedVhdAsync;
|
||||
use self::fixed::FixedVhd;
|
||||
use crate::async_io::{AsyncIo, BorrowedDiskFd, DiskFileError};
|
||||
use crate::disk_file::DiskSize;
|
||||
use crate::error::{BlockError, BlockErrorKind, BlockResult, ErrorOp};
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright 2026 The Cloud Hypervisor Authors. All rights reserved.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
//! Sync/async I/O workers for fixed VHD images.
|
||||
//!
|
||||
//! Thin wrappers around the raw workers that clamp I/O to the
|
||||
//! virtual disk size.
|
||||
|
||||
#[cfg(feature = "io_uring")]
|
||||
pub(crate) mod async_uring;
|
||||
pub(crate) mod sync;
|
||||
Reference in New Issue
Block a user