mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 16:27:50 +00:00
runitme-rs: kata with multi-containers sharing one direct volume
When multiple containers in a kata pod share one direct volume, it's important to make sure that the corresponding block device is only mounted once in the guest. This means that there should be only one mount entry for the device in the mount information. Fixes: #8328 Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
This commit is contained in:
parent
d7594d830c
commit
ba632ba825
@ -35,7 +35,6 @@ impl BlockVolume {
|
||||
d: &RwLock<DeviceManager>,
|
||||
m: &oci::Mount,
|
||||
read_only: bool,
|
||||
cid: &str,
|
||||
sid: &str,
|
||||
) -> Result<Self> {
|
||||
let mnt_src: &str = &m.source;
|
||||
@ -97,21 +96,14 @@ impl BlockVolume {
|
||||
.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(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
storage.options = if read_only {
|
||||
options: if read_only {
|
||||
vec!["ro".to_string()]
|
||||
} else {
|
||||
Vec::new()
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
// As the true Block Device wrapped in DeviceType, we need to
|
||||
@ -127,6 +119,12 @@ impl BlockVolume {
|
||||
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();
|
||||
|
||||
// In some case, dest is device /dev/xxx
|
||||
if m.destination.clone().starts_with("/dev") {
|
||||
storage.fs_type = "bind".to_string();
|
||||
|
@ -77,7 +77,7 @@ impl VolumeResource {
|
||||
} else if is_block_volume(m).context("block volume type")? {
|
||||
// handle block volume
|
||||
Arc::new(
|
||||
block_volume::BlockVolume::new(d, m, read_only, cid, sid)
|
||||
block_volume::BlockVolume::new(d, m, read_only, sid)
|
||||
.await
|
||||
.with_context(|| format!("new share fs volume {:?}", m))?,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user