mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-17 14:58:16 +00:00
runtime-rs: Add support for configurable block device aio
AIO is the I/O mechanism used by qemu with options: - threads Pthread based disk I/O. - native Native Linux I/O. - io_uring (default mode) Linux io_uring API. This provides the fastest I/O operations on Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
This commit is contained in:
@@ -37,6 +37,9 @@ pub const DEFAULT_INTERNETWORKING_MODEL: &str = "tcfilter";
|
||||
pub const DEFAULT_BLOCK_DEVICE_TYPE: &str = "virtio-blk-pci";
|
||||
pub const DEFAULT_VHOST_USER_STORE_PATH: &str = "/var/run/vhost-user";
|
||||
pub const DEFAULT_BLOCK_NVDIMM_MEM_OFFSET: u64 = 0;
|
||||
pub const DEFAULT_BLOCK_DEVICE_AIO_THREADS: &str = "threads";
|
||||
pub const DEFAULT_BLOCK_DEVICE_AIO_NATIVE: &str = "native";
|
||||
pub const DEFAULT_BLOCK_DEVICE_AIO: &str = "io_uring";
|
||||
|
||||
pub const DEFAULT_SHARED_FS_TYPE: &str = "virtio-fs";
|
||||
pub const DEFAULT_VIRTIO_FS_CACHE_MODE: &str = "never";
|
||||
|
@@ -107,6 +107,21 @@ pub struct BlockDeviceInfo {
|
||||
#[serde(default)]
|
||||
pub block_device_driver: String,
|
||||
|
||||
/// Block device AIO is the I/O mechanism specially for Qemu
|
||||
/// Options:
|
||||
///
|
||||
/// - threads
|
||||
/// Pthread based disk I/O.
|
||||
///
|
||||
/// - native
|
||||
/// Native Linux I/O.
|
||||
///
|
||||
/// - io_uring
|
||||
/// Linux io_uring API. This provides the fastest I/O operations on Linux, requires kernel > 5.1 and
|
||||
/// qemu >= 5.0.
|
||||
#[serde(default)]
|
||||
pub block_device_aio: String,
|
||||
|
||||
/// Specifies cache-related options will be set to block devices or not.
|
||||
#[serde(default)]
|
||||
pub block_device_cache_set: bool,
|
||||
@@ -168,6 +183,21 @@ impl BlockDeviceInfo {
|
||||
if self.block_device_driver.is_empty() {
|
||||
self.block_device_driver = default::DEFAULT_BLOCK_DEVICE_TYPE.to_string();
|
||||
}
|
||||
if self.block_device_aio.is_empty() {
|
||||
self.block_device_aio = default::DEFAULT_BLOCK_DEVICE_AIO.to_string();
|
||||
} else {
|
||||
const VALID_BLOCK_DEVICE_AIO: &[&str] = &[
|
||||
default::DEFAULT_BLOCK_DEVICE_AIO,
|
||||
default::DEFAULT_BLOCK_DEVICE_AIO_NATIVE,
|
||||
default::DEFAULT_BLOCK_DEVICE_AIO_THREADS,
|
||||
];
|
||||
if !VALID_BLOCK_DEVICE_AIO.contains(&self.block_device_aio.as_str()) {
|
||||
return Err(eother!(
|
||||
"{} is unsupported block device AIO mode.",
|
||||
self.block_device_aio
|
||||
));
|
||||
}
|
||||
}
|
||||
if self.memory_offset == 0 {
|
||||
self.memory_offset = default::DEFAULT_BLOCK_NVDIMM_MEM_OFFSET;
|
||||
}
|
||||
|
Reference in New Issue
Block a user