vmm: device_manager: Wire up QcowDiskAsync with io_uring

When io_uring is available and not disabled, open QCOW2 images
with QcowDiskAsync for asynchronous reads. Falls back to
QcowDiskSync otherwise.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-03-20 20:30:53 +01:00
committed by Rob Bradford
parent ffc579b913
commit 3d5a40dfa6
+46 -14
View File
@@ -35,6 +35,8 @@ use arch::{NumaNodes, layout};
use block::disk_file::DiskBackend; use block::disk_file::DiskBackend;
use block::error::BlockError; use block::error::BlockError;
use block::fixed_vhd_sync::FixedVhdDiskSync; use block::fixed_vhd_sync::FixedVhdDiskSync;
#[cfg(feature = "io_uring")]
use block::qcow_async::QcowDiskAsync;
use block::qcow_sync::QcowDiskSync; use block::qcow_sync::QcowDiskSync;
use block::raw_async_aio::RawFileDiskAio; use block::raw_async_aio::RawFileDiskAio;
use block::raw_sync::RawFileDiskSync; use block::raw_sync::RawFileDiskSync;
@@ -591,6 +593,10 @@ pub enum DeviceManagerError {
#[error("Failed to create QcowDiskSync")] #[error("Failed to create QcowDiskSync")]
CreateQcowDiskSync(#[source] BlockError), CreateQcowDiskSync(#[source] BlockError),
/// Failed to create QcowDiskAsync
#[error("Failed to create QcowDiskAsync")]
CreateQcowDiskAsync(#[source] BlockError),
/// Failed to create FixedVhdxDiskSync /// Failed to create FixedVhdxDiskSync
#[error("Failed to create FixedVhdxDiskSync")] #[error("Failed to create FixedVhdxDiskSync")]
CreateFixedVhdxDiskSync(#[source] BlockError), CreateFixedVhdxDiskSync(#[source] BlockError),
@@ -2801,20 +2807,46 @@ impl DeviceManager {
} }
} }
ImageType::Qcow2 => { ImageType::Qcow2 => {
info!("Using synchronous QCOW2 disk file"); if cfg!(feature = "io_uring")
DiskBackend::Next(Box::new( && !disk_cfg.disable_io_uring
QcowDiskSync::new( && self.io_uring_is_supported()
file, {
disk_cfg.direct, info!("Using asynchronous QCOW2 disk file (io_uring)");
disk_cfg.backing_files,
disk_cfg.sparse, #[cfg(not(feature = "io_uring"))]
) unreachable!("Checked in if statement above");
.map_err(|e| match &disk_cfg.path { #[cfg(feature = "io_uring")]
Some(p) => e.with_path(p), {
None => e, DiskBackend::Next(Box::new(
}) QcowDiskAsync::new(
.map_err(DeviceManagerError::CreateQcowDiskSync)?, file,
)) disk_cfg.direct,
disk_cfg.backing_files,
disk_cfg.sparse,
)
.map_err(|e| match &disk_cfg.path {
Some(p) => e.with_path(p),
None => e,
})
.map_err(DeviceManagerError::CreateQcowDiskAsync)?,
))
}
} else {
info!("Using synchronous QCOW2 disk file");
DiskBackend::Next(Box::new(
QcowDiskSync::new(
file,
disk_cfg.direct,
disk_cfg.backing_files,
disk_cfg.sparse,
)
.map_err(|e| match &disk_cfg.path {
Some(p) => e.with_path(p),
None => e,
})
.map_err(DeviceManagerError::CreateQcowDiskSync)?,
))
}
} }
ImageType::Vhdx => { ImageType::Vhdx => {
info!("Using synchronous VHDX disk file"); info!("Using synchronous VHDX disk file");