runtime-rs: use device manager to handle virtio-pmem

use device manager to handle virtio-pmem device

Fixes: #7119
Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
This commit is contained in:
Zhongtao Hu
2023-06-26 09:47:32 +08:00
parent 901c192251
commit c8fcd29d9b
8 changed files with 147 additions and 62 deletions

View File

@@ -11,7 +11,7 @@ use anyhow::{anyhow, Context, Result};
use async_trait::async_trait;
use hypervisor::{
device::{
device_manager::{do_handle_device, DeviceManager},
device_manager::{do_handle_device, get_block_driver, DeviceManager},
DeviceConfig, DeviceType,
},
BlockConfig,
@@ -43,9 +43,12 @@ 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_driver(d).await;
let block_device_config = &mut BlockConfig {
major: stat::major(dev_id) as i64,
minor: stat::minor(dev_id) as i64,
driver_option: block_driver,
..Default::default()
};

View File

@@ -16,7 +16,7 @@ use crate::volume::utils::{
};
use hypervisor::{
device::{
device_manager::{do_handle_device, DeviceManager},
device_manager::{do_handle_device, get_block_driver, DeviceManager},
DeviceConfig, DeviceType,
},
BlockConfig,
@@ -42,6 +42,8 @@ impl BlockVolume {
// default block device fs type: ext4.
let mut blk_dev_fstype = DEFAULT_VOLUME_FS_TYPE.to_string();
let block_driver = get_block_driver(d).await;
let block_device_config = match m.r#type.as_str() {
KATA_MOUNT_BIND_TYPE => {
let fstat = stat::stat(mnt_src).context(format!("stat {}", m.source))?;
@@ -49,6 +51,7 @@ impl BlockVolume {
BlockConfig {
major: stat::major(fstat.st_rdev) as i64,
minor: stat::minor(fstat.st_rdev) as i64,
driver_option: block_driver,
..Default::default()
}
}
@@ -77,6 +80,7 @@ impl BlockVolume {
BlockConfig {
path_on_host: v.device,
driver_option: block_driver,
..Default::default()
}
}

View File

@@ -16,7 +16,7 @@ use crate::volume::utils::{
};
use hypervisor::{
device::{
device_manager::{do_handle_device, DeviceManager},
device_manager::{do_handle_device, get_block_driver, DeviceManager},
DeviceConfig, DeviceType,
},
VhostUserConfig, VhostUserType,
@@ -73,9 +73,12 @@ impl SPDKVolume {
}
}
let vhu_blk_config = &mut VhostUserConfig {
let block_driver = get_block_driver(d).await;
let mut vhu_blk_config = &mut VhostUserConfig {
socket_path: device,
device_type: VhostUserType::Blk("vhost-user-blk-pci".to_owned()),
driver_option: block_driver,
..Default::default()
};