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>, d: &RwLock<DeviceManager>,
m: &oci::Mount, m: &oci::Mount,
read_only: bool, read_only: bool,
cid: &str,
sid: &str, sid: &str,
) -> Result<Self> { ) -> Result<Self> {
let mnt_src: &str = &m.source; let mnt_src: &str = &m.source;
@@ -100,21 +99,14 @@ impl SPDKVolume {
.await .await
.context("do handle device failed.")?; .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 // storage
let mut storage = agent::Storage { let mut storage = agent::Storage {
mount_point: guest_path.clone(), options: if read_only {
..Default::default()
};
storage.options = if read_only {
vec!["ro".to_string()] vec!["ro".to_string()]
} else { } else {
Vec::new() Vec::new()
},
..Default::default()
}; };
let mut device_id = String::new(); let mut device_id = String::new();
@@ -126,6 +118,12 @@ impl SPDKVolume {
device_id = device.device_id; 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" { if m.r#type != "bind" {
storage.fs_type = v.fs_type.clone(); storage.fs_type = v.fs_type.clone();
} else { } else {

View File

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