block: vhd: Rename FixedVhdDisk to VhdDisk

FixedVhdDisk is the format level DiskFile wrapper for VHD images.
Rename it to VhdDisk to match the <Format>Disk convention used by
RawDisk, QcowDisk, and VhdxDisk. The Fixed prefix remains on the
workers (FixedVhdSync, FixedVhdAsync) since those are specific to
the fixed subformat.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-04-24 18:15:57 +02:00
committed by Rob Bradford
parent 82e1c08e1f
commit 2689cf9bdb
2 changed files with 22 additions and 22 deletions

View File

@@ -20,7 +20,7 @@ use log::info;
use crate::block_io_uring_is_supported;
use crate::disk_file::AsyncFullDiskFile;
use crate::error::{BlockError, BlockErrorKind, BlockResult};
use crate::fixed_vhd_disk::FixedVhdDisk;
use crate::fixed_vhd_disk::VhdDisk;
use crate::qcow_disk::QcowDisk;
use crate::raw_disk::{RawBackend, RawDisk};
use crate::vhdx_sync::VhdxDisk;
@@ -127,7 +127,7 @@ fn open_fixed_vhd(
if io_uring_supported() {
info!("Opening fixed VHD disk file with io_uring backend");
return Ok(Box::new(
FixedVhdDisk::new(file, true).map_err(|e| e.with_path(options.path))?,
VhdDisk::new(file, true).map_err(|e| e.with_path(options.path))?,
));
}
info!("io_uring runtime probe failed for fixed VHD, using synchronous backend");
@@ -135,7 +135,7 @@ fn open_fixed_vhd(
info!("Opening fixed VHD disk file with synchronous backend");
Ok(Box::new(
FixedVhdDisk::new(file, false).map_err(|e| e.with_path(options.path))?,
VhdDisk::new(file, false).map_err(|e| e.with_path(options.path))?,
))
}

View File

@@ -18,12 +18,12 @@ use crate::fixed_vhd_sync::FixedVhdSync;
use crate::{BlockBackend, Error, disk_file};
#[derive(Debug)]
pub struct FixedVhdDisk {
pub struct VhdDisk {
inner: FixedVhd,
use_io_uring: bool,
}
impl FixedVhdDisk {
impl VhdDisk {
pub fn new(file: File, use_io_uring: bool) -> BlockResult<Self> {
#[cfg(not(feature = "io_uring"))]
if use_io_uring {
@@ -42,7 +42,7 @@ impl FixedVhdDisk {
}
}
impl disk_file::DiskSize for FixedVhdDisk {
impl disk_file::DiskSize for VhdDisk {
fn logical_size(&self) -> BlockResult<u64> {
self.inner
.logical_size()
@@ -50,7 +50,7 @@ impl disk_file::DiskSize for FixedVhdDisk {
}
}
impl disk_file::PhysicalSize for FixedVhdDisk {
impl disk_file::PhysicalSize for VhdDisk {
fn physical_size(&self) -> BlockResult<u64> {
self.inner.physical_size().map_err(|e| match e {
Error::GetFileMetadata(io) => {
@@ -61,17 +61,17 @@ impl disk_file::PhysicalSize for FixedVhdDisk {
}
}
impl disk_file::DiskFd for FixedVhdDisk {
impl disk_file::DiskFd for VhdDisk {
fn fd(&self) -> BorrowedDiskFd<'_> {
BorrowedDiskFd::new(self.inner.as_raw_fd())
}
}
impl disk_file::Geometry for FixedVhdDisk {}
impl disk_file::Geometry for VhdDisk {}
impl disk_file::SparseCapable for FixedVhdDisk {}
impl disk_file::SparseCapable for VhdDisk {}
impl disk_file::Resizable for FixedVhdDisk {
impl disk_file::Resizable for VhdDisk {
fn resize(&mut self, _size: u64) -> BlockResult<()> {
Err(BlockError::new(
BlockErrorKind::UnsupportedFeature,
@@ -81,11 +81,11 @@ impl disk_file::Resizable for FixedVhdDisk {
}
}
impl disk_file::DiskFile for FixedVhdDisk {}
impl disk_file::DiskFile for VhdDisk {}
impl disk_file::AsyncDiskFile for FixedVhdDisk {
impl disk_file::AsyncDiskFile for VhdDisk {
fn try_clone(&self) -> BlockResult<Box<dyn disk_file::AsyncDiskFile>> {
Ok(Box::new(FixedVhdDisk {
Ok(Box::new(VhdDisk {
inner: self.inner.clone(),
use_io_uring: self.use_io_uring,
}))
@@ -166,7 +166,7 @@ mod unit_tests {
#[test]
fn new_sync_returns_correct_size() {
let file = make_vhd_file();
let disk = FixedVhdDisk::new(file, false).unwrap();
let disk = VhdDisk::new(file, false).unwrap();
assert_eq!(disk.logical_size().unwrap(), 0x1122_3344);
}
@@ -175,14 +175,14 @@ mod unit_tests {
assert_eq!(io.batch_requests_enabled(), expect_batch);
}
fn assert_async_io(disk: &FixedVhdDisk, expect_batch: bool) {
fn assert_async_io(disk: &VhdDisk, expect_batch: bool) {
assert_async_io_from_dyn(disk, expect_batch);
}
#[test]
fn sync_backend_disables_batch_requests() {
let file = make_vhd_file();
let disk = FixedVhdDisk::new(file, false).unwrap();
let disk = VhdDisk::new(file, false).unwrap();
assert_async_io(&disk, false);
}
@@ -190,7 +190,7 @@ mod unit_tests {
#[test]
fn io_uring_backend_enables_batch_requests() {
let file = make_vhd_file();
let disk = FixedVhdDisk::new(file, true).unwrap();
let disk = VhdDisk::new(file, true).unwrap();
assert_async_io(&disk, true);
}
@@ -211,7 +211,7 @@ mod unit_tests {
#[test]
fn try_clone_preserves_sync_dispatch() {
let file = make_vhd_file();
let disk = FixedVhdDisk::new(file, false).unwrap();
let disk = VhdDisk::new(file, false).unwrap();
let cloned = disk.try_clone().unwrap();
assert_async_io_from_dyn(cloned.as_ref(), false);
}
@@ -220,7 +220,7 @@ mod unit_tests {
#[test]
fn try_clone_preserves_io_uring_dispatch() {
let file = make_vhd_file();
let disk = FixedVhdDisk::new(file, true).unwrap();
let disk = VhdDisk::new(file, true).unwrap();
let cloned = disk.try_clone().unwrap();
assert_async_io_from_dyn(cloned.as_ref(), true);
}
@@ -228,14 +228,14 @@ mod unit_tests {
#[test]
fn resize_returns_error() {
let file = make_vhd_file();
let mut disk = FixedVhdDisk::new(file, false).unwrap();
let mut disk = VhdDisk::new(file, false).unwrap();
assert!(disk.resize(0x2000_0000).is_err());
}
#[test]
fn physical_size_includes_footer() {
let file = make_vhd_file();
let disk = FixedVhdDisk::new(file, false).unwrap();
let disk = VhdDisk::new(file, false).unwrap();
// Data region (0x1122_3344) + VHD footer (0x200).
assert_eq!(disk.physical_size().unwrap(), 0x1122_3344 + 0x200);
}