mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-11-02 02:25:50 +00:00
runtime-rs: Allow per-device AIO mode configuration for block devices
This commit enhances control over block device AIO modes via hotplug. Previously, hotplugging block devices was set with default AIO mode (io_uring). Even if users reset the AIO mode in the configuration file, the changes would not be correctly applied to individual block devices. With this update, users can now explicitly configure the AIO mode for hot-plugging block devices via the configuration, and those settings will be correctly applied. Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
This commit is contained in:
@@ -15,7 +15,7 @@ use hypervisor::{
|
||||
util::{get_host_path, DEVICE_TYPE_CHAR},
|
||||
DeviceConfig, DeviceType,
|
||||
},
|
||||
BlockConfig, Hypervisor, VfioConfig,
|
||||
BlockConfig, BlockDeviceAio, Hypervisor, VfioConfig,
|
||||
};
|
||||
use kata_types::mount::{
|
||||
Mount, DEFAULT_KATA_GUEST_SANDBOX_DIR, KATA_EPHEMERAL_VOLUME_TYPE, SHM_DIR,
|
||||
@@ -418,10 +418,14 @@ impl ResourceManagerInner {
|
||||
let block_driver = get_block_device_info(&self.device_manager)
|
||||
.await
|
||||
.block_device_driver;
|
||||
let aio = get_block_device_info(&self.device_manager)
|
||||
.await
|
||||
.block_device_aio;
|
||||
let dev_info = DeviceConfig::BlockCfg(BlockConfig {
|
||||
major: d.major(),
|
||||
minor: d.minor(),
|
||||
driver_option: block_driver,
|
||||
blkdev_aio: BlockDeviceAio::new(&aio),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ use hypervisor::{
|
||||
device_manager::{do_handle_device, get_block_device_info, DeviceManager},
|
||||
DeviceConfig, DeviceType,
|
||||
},
|
||||
BlockConfig,
|
||||
BlockConfig, BlockDeviceAio,
|
||||
};
|
||||
use kata_types::config::hypervisor::{
|
||||
VIRTIO_BLK_CCW, VIRTIO_BLK_MMIO, VIRTIO_BLK_PCI, VIRTIO_PMEM, VIRTIO_SCSI,
|
||||
@@ -50,13 +50,14 @@ impl BlockRootfs {
|
||||
fs::create_dir_all(&host_path)
|
||||
.map_err(|e| anyhow!("failed to create rootfs dir {}: {:?}", host_path, e))?;
|
||||
|
||||
let block_driver = get_block_device_info(d).await.block_device_driver;
|
||||
|
||||
let blkdev_info = get_block_device_info(d).await;
|
||||
let block_driver = blkdev_info.block_device_driver.clone();
|
||||
let block_device_config = &mut BlockConfig {
|
||||
major: stat::major(dev_id) as i64,
|
||||
minor: stat::minor(dev_id) as i64,
|
||||
driver_option: block_driver.clone(),
|
||||
path_on_host: rootfs.source.clone(),
|
||||
blkdev_aio: BlockDeviceAio::new(&blkdev_info.block_device_aio),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ use hypervisor::{
|
||||
device_manager::{do_handle_device, get_block_device_info, DeviceManager},
|
||||
DeviceConfig,
|
||||
},
|
||||
BlockConfig,
|
||||
BlockConfig, BlockDeviceAio,
|
||||
};
|
||||
use kata_sys_util::mount::get_mount_path;
|
||||
use nix::sys::{stat, stat::SFlag};
|
||||
@@ -39,12 +39,14 @@ impl BlockVolume {
|
||||
Some(path) => path,
|
||||
None => return Err(anyhow!("mount source path is empty")),
|
||||
};
|
||||
let block_driver = get_block_device_info(d).await.block_device_driver;
|
||||
|
||||
let blkdev_info = get_block_device_info(d).await;
|
||||
let fstat = stat::stat(mnt_src).context(format!("stat {}", mnt_src.display()))?;
|
||||
let block_device_config = BlockConfig {
|
||||
major: stat::major(fstat.st_rdev) as i64,
|
||||
minor: stat::minor(fstat.st_rdev) as i64,
|
||||
driver_option: block_driver,
|
||||
driver_option: blkdev_info.block_device_driver,
|
||||
blkdev_aio: BlockDeviceAio::new(&blkdev_info.block_device_aio),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ use hypervisor::{
|
||||
device_manager::{do_handle_device, get_block_device_info, DeviceManager},
|
||||
DeviceConfig,
|
||||
},
|
||||
BlockConfig,
|
||||
BlockConfig, BlockDeviceAio,
|
||||
};
|
||||
use kata_types::mount::DirectVolumeMountInfo;
|
||||
use nix::sys::{stat, stat::SFlag};
|
||||
@@ -36,7 +36,7 @@ impl RawblockVolume {
|
||||
read_only: bool,
|
||||
sid: &str,
|
||||
) -> Result<Self> {
|
||||
let block_driver = get_block_device_info(d).await.block_device_driver;
|
||||
let blkdev_info = get_block_device_info(d).await;
|
||||
|
||||
// check volume type
|
||||
if mount_info.volume_type != KATA_DIRECT_VOLUME_TYPE {
|
||||
@@ -60,7 +60,8 @@ impl RawblockVolume {
|
||||
|
||||
let block_config = BlockConfig {
|
||||
path_on_host: mount_info.device.clone(),
|
||||
driver_option: block_driver,
|
||||
driver_option: blkdev_info.block_device_driver,
|
||||
blkdev_aio: BlockDeviceAio::new(&blkdev_info.block_device_aio),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user