runtime-rs: add support kata/multi-containers sharing one spdk volume.

Fiexes: #8300

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
This commit is contained in:
alex.lyn
2023-11-25 21:13:03 +08:00
parent 17d2d465d1
commit b952c5c5ce
2 changed files with 12 additions and 14 deletions

View File

@@ -36,7 +36,6 @@ impl SPDKVolume {
d: &RwLock<DeviceManager>,
m: &oci::Mount,
read_only: bool,
cid: &str,
sid: &str,
) -> Result<Self> {
let mnt_src: &str = &m.source;
@@ -100,23 +99,16 @@ impl SPDKVolume {
.await
.context("do handle device failed.")?;
// generate host guest shared path
let guest_path = generate_shared_path(m.destination.clone(), read_only, cid, sid)
.await
.context("generate host-guest shared path failed")?;
// storage
let mut storage = agent::Storage {
mount_point: guest_path.clone(),
options: if read_only {
vec!["ro".to_string()]
} else {
Vec::new()
},
..Default::default()
};
storage.options = if read_only {
vec!["ro".to_string()]
} else {
Vec::new()
};
let mut device_id = String::new();
if let DeviceType::VhostUserBlk(device) = device_info {
// blk, mmioblk
@@ -126,6 +118,12 @@ impl SPDKVolume {
device_id = device.device_id;
}
// generate host guest shared path
let guest_path = generate_shared_path(m.destination.clone(), read_only, &device_id, sid)
.await
.context("generate host-guest shared path failed")?;
storage.mount_point = guest_path.clone();
if m.r#type != "bind" {
storage.fs_type = v.fs_type.clone();
} else {

View File

@@ -97,7 +97,7 @@ impl VolumeResource {
)
} else if is_spdk_volume(m) {
Arc::new(
SPDKVolume::new(d, m, read_only, cid, sid)
SPDKVolume::new(d, m, read_only, sid)
.await
.with_context(|| format!("create spdk volume {:?}", m))?,
)