mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-27 07:48:55 +00:00
runtime-rs: correct the path from cid to device_id.
When a direct volume is used by multiple containers in Kata, Generating many shared paths with cids will cause IO error as the result of one direct volume mounts more than once. To correct it, use the device_id instead of cid which ensures that the guest only mounts the FS once. Fixes: #8328 Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
This commit is contained in:
parent
906f6b7380
commit
d7594d830c
@ -57,13 +57,13 @@ pub fn get_file_name<P: AsRef<Path>>(src: P) -> Result<String> {
|
||||
pub(crate) async fn generate_shared_path(
|
||||
dest: String,
|
||||
read_only: bool,
|
||||
cid: &str,
|
||||
device_id: &str,
|
||||
sid: &str,
|
||||
) -> Result<String> {
|
||||
let file_name = get_file_name(&dest).context("failed to get file name.")?;
|
||||
let mount_name = generate_mount_path(cid, file_name.as_str());
|
||||
let guest_path = do_get_guest_path(&mount_name, cid, true, false);
|
||||
let host_path = do_get_host_path(&mount_name, sid, cid, true, read_only);
|
||||
let mount_name = generate_mount_path(device_id, file_name.as_str());
|
||||
let guest_path = do_get_guest_path(&mount_name, device_id, true, false);
|
||||
let host_path = do_get_host_path(&mount_name, sid, device_id, true, read_only);
|
||||
|
||||
if dest.starts_with("/dev") {
|
||||
fs::File::create(&host_path).context(format!("failed to create file {:?}", &host_path))?;
|
||||
|
Loading…
Reference in New Issue
Block a user