mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: add aio disk backend
Signed-off-by: Thomas Barrett <tbarrett@crusoeenergy.com>
This commit is contained in:
@@ -888,6 +888,7 @@ impl DiskConfig {
|
||||
.add("ops_refill_time")
|
||||
.add("id")
|
||||
.add("_disable_io_uring")
|
||||
.add("_disable_aio")
|
||||
.add("pci_segment")
|
||||
.add("serial");
|
||||
parser.parse(disk).map_err(Error::ParseDisk)?;
|
||||
@@ -928,6 +929,11 @@ impl DiskConfig {
|
||||
.map_err(Error::ParseDisk)?
|
||||
.unwrap_or(Toggle(false))
|
||||
.0;
|
||||
let disable_aio = parser
|
||||
.convert::<Toggle>("_disable_aio")
|
||||
.map_err(Error::ParseDisk)?
|
||||
.unwrap_or(Toggle(false))
|
||||
.0;
|
||||
let pci_segment = parser
|
||||
.convert("pci_segment")
|
||||
.map_err(Error::ParseDisk)?
|
||||
@@ -996,6 +1002,7 @@ impl DiskConfig {
|
||||
rate_limiter_config,
|
||||
id,
|
||||
disable_io_uring,
|
||||
disable_aio,
|
||||
pci_segment,
|
||||
serial,
|
||||
})
|
||||
|
||||
@@ -35,9 +35,9 @@ use arch::NumaNodes;
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use arch::{DeviceType, MmioDeviceInfo};
|
||||
use block::{
|
||||
async_io::DiskFile, block_io_uring_is_supported, detect_image_type,
|
||||
fixed_vhd_sync::FixedVhdDiskSync, qcow, qcow_sync::QcowDiskSync, raw_sync::RawFileDiskSync,
|
||||
vhdx, vhdx_sync::VhdxDiskSync, ImageType,
|
||||
async_io::DiskFile, block_aio_is_supported, block_io_uring_is_supported, detect_image_type,
|
||||
fixed_vhd_sync::FixedVhdDiskSync, qcow, qcow_sync::QcowDiskSync, raw_async_aio::RawFileDiskAio,
|
||||
raw_sync::RawFileDiskSync, vhdx, vhdx_sync::VhdxDiskSync, ImageType,
|
||||
};
|
||||
#[cfg(feature = "io_uring")]
|
||||
use block::{fixed_vhd_async::FixedVhdDiskAsync, raw_async::RawFileDisk};
|
||||
@@ -949,6 +949,9 @@ pub struct DeviceManager {
|
||||
// io_uring availability if detected
|
||||
io_uring_supported: Option<bool>,
|
||||
|
||||
// aio availability if detected
|
||||
aio_supported: Option<bool>,
|
||||
|
||||
// List of unique identifiers provided at boot through the configuration.
|
||||
boot_id_list: BTreeSet<String>,
|
||||
|
||||
@@ -1138,6 +1141,7 @@ impl DeviceManager {
|
||||
pvpanic_device: None,
|
||||
force_iommu,
|
||||
io_uring_supported: None,
|
||||
aio_supported: None,
|
||||
boot_id_list,
|
||||
timestamp,
|
||||
pending_activations: Arc::new(Mutex::new(Vec::default())),
|
||||
@@ -2171,6 +2175,17 @@ impl DeviceManager {
|
||||
Ok(devices)
|
||||
}
|
||||
|
||||
// Cache whether aio is supported to avoid checking for very block device
|
||||
fn aio_is_supported(&mut self) -> bool {
|
||||
if let Some(supported) = self.aio_supported {
|
||||
return supported;
|
||||
}
|
||||
|
||||
let supported = block_aio_is_supported();
|
||||
self.aio_supported = Some(supported);
|
||||
supported
|
||||
}
|
||||
|
||||
// Cache whether io_uring is supported to avoid probing for very block device
|
||||
fn io_uring_is_supported(&mut self) -> bool {
|
||||
if let Some(supported) = self.io_uring_supported {
|
||||
@@ -2292,6 +2307,9 @@ impl DeviceManager {
|
||||
{
|
||||
Box::new(RawFileDisk::new(file)) as Box<dyn DiskFile>
|
||||
}
|
||||
} else if !disk_cfg.disable_aio && self.aio_is_supported() {
|
||||
info!("Using asynchronous RAW disk file (aio)");
|
||||
Box::new(RawFileDiskAio::new(file)) as Box<dyn DiskFile>
|
||||
} else {
|
||||
info!("Using synchronous RAW disk file");
|
||||
Box::new(RawFileDiskSync::new(file)) as Box<dyn DiskFile>
|
||||
|
||||
@@ -553,6 +553,11 @@ fn vmm_thread_rules(
|
||||
libc::SYS_ioctl,
|
||||
create_vmm_ioctl_seccomp_rule(hypervisor_type)?,
|
||||
),
|
||||
(libc::SYS_io_cancel, vec![]),
|
||||
(libc::SYS_io_destroy, vec![]),
|
||||
(libc::SYS_io_getevents, vec![]),
|
||||
(libc::SYS_io_setup, vec![]),
|
||||
(libc::SYS_io_submit, vec![]),
|
||||
(libc::SYS_io_uring_enter, vec![]),
|
||||
(libc::SYS_io_uring_setup, vec![]),
|
||||
(libc::SYS_io_uring_register, vec![]),
|
||||
|
||||
@@ -218,6 +218,9 @@ pub struct DiskConfig {
|
||||
// For testing use only. Not exposed in API.
|
||||
#[serde(default)]
|
||||
pub disable_io_uring: bool,
|
||||
// For testing use only. Not exposed in API.
|
||||
#[serde(default)]
|
||||
pub disable_aio: bool,
|
||||
#[serde(default)]
|
||||
pub pci_segment: u16,
|
||||
#[serde(default)]
|
||||
@@ -249,6 +252,7 @@ impl Default for DiskConfig {
|
||||
vhost_socket: None,
|
||||
id: None,
|
||||
disable_io_uring: false,
|
||||
disable_aio: false,
|
||||
rate_limiter_config: None,
|
||||
pci_segment: 0,
|
||||
serial: None,
|
||||
|
||||
Reference in New Issue
Block a user