From 2600fc6f438235c33836516d2f4b8d534fed84c6 Mon Sep 17 00:00:00 2001 From: "alex.lyn" Date: Sun, 1 Jun 2025 21:58:39 +0800 Subject: [PATCH] runtime-rs: Add Spec annotation to help pass image information We need get the relevent image ref from OCI runtime Spec, especially the annotation of it. Fixes #10690 Signed-off-by: alex.lyn --- src/runtime-rs/crates/resource/src/manager.rs | 4 +++- src/runtime-rs/crates/resource/src/manager_inner.rs | 4 +++- src/runtime-rs/crates/resource/src/rootfs/mod.rs | 3 ++- .../virt_container/src/container_manager/container.rs | 3 +++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/runtime-rs/crates/resource/src/manager.rs b/src/runtime-rs/crates/resource/src/manager.rs index f2b35996fb..05e0b04605 100644 --- a/src/runtime-rs/crates/resource/src/manager.rs +++ b/src/runtime-rs/crates/resource/src/manager.rs @@ -4,6 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 // +use std::collections::HashMap; use std::sync::Arc; use agent::{Agent, Storage}; @@ -100,10 +101,11 @@ impl ResourceManager { root: &oci::Root, bundle_path: &str, rootfs_mounts: &[Mount], + annotations: &HashMap, ) -> Result> { let inner = self.inner.read().await; inner - .handler_rootfs(cid, root, bundle_path, rootfs_mounts) + .handler_rootfs(cid, root, bundle_path, rootfs_mounts, annotations) .await } diff --git a/src/runtime-rs/crates/resource/src/manager_inner.rs b/src/runtime-rs/crates/resource/src/manager_inner.rs index ba5eae5cf5..f8d40cff72 100644 --- a/src/runtime-rs/crates/resource/src/manager_inner.rs +++ b/src/runtime-rs/crates/resource/src/manager_inner.rs @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 // -use std::{sync::Arc, thread}; +use std::{collections::HashMap, sync::Arc, thread}; use agent::{types::Device, Agent, OnlineCPUMemRequest, Storage}; use anyhow::{anyhow, Context, Ok, Result}; @@ -320,6 +320,7 @@ impl ResourceManagerInner { root: &oci::Root, bundle_path: &str, rootfs_mounts: &[Mount], + annotations: &HashMap, ) -> Result> { self.rootfs_resource .handler_rootfs( @@ -331,6 +332,7 @@ impl ResourceManagerInner { root, bundle_path, rootfs_mounts, + annotations, ) .await } diff --git a/src/runtime-rs/crates/resource/src/rootfs/mod.rs b/src/runtime-rs/crates/resource/src/rootfs/mod.rs index c33854870b..61317daaa4 100644 --- a/src/runtime-rs/crates/resource/src/rootfs/mod.rs +++ b/src/runtime-rs/crates/resource/src/rootfs/mod.rs @@ -14,7 +14,7 @@ mod block_rootfs; pub mod virtual_volume; use hypervisor::{device::device_manager::DeviceManager, Hypervisor}; -use std::{sync::Arc, vec::Vec}; +use std::{collections::HashMap, sync::Arc, vec::Vec}; use tokio::sync::RwLock; use self::{block_rootfs::is_block_rootfs, nydus_rootfs::NYDUS_ROOTFS_TYPE}; @@ -67,6 +67,7 @@ impl RootFsResource { root: &oci::Root, bundle_path: &str, rootfs_mounts: &[Mount], + _annotations: &HashMap, ) -> Result> { match rootfs_mounts { // if rootfs_mounts is empty diff --git a/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/container.rs b/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/container.rs index 75c6427c0a..93cd6effd0 100644 --- a/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/container.rs +++ b/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/container.rs @@ -110,6 +110,8 @@ impl Container { // is 'true'. None => true, }; + let annotations = spec.annotations().clone().unwrap_or_default(); + amend_spec( &mut spec, toml_config.runtime.disable_guest_seccomp, @@ -131,6 +133,7 @@ impl Container { root, &config.bundle, &config.rootfs_mounts, + &annotations, ) .await .context("handler rootfs")?;