runtime-rs: Change Rootfs::get_storage return type

Change Rootfs::get_storage to return Option<Vec<Storage>>
to support multi-layer rootfs with multiple storages.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
This commit is contained in:
Alex Lyn
2026-03-31 17:18:10 +08:00
parent 929dd271a0
commit bde5702970
6 changed files with 11 additions and 10 deletions

View File

@@ -137,8 +137,8 @@ impl Rootfs for BlockRootfs {
Ok(vec![self.mount.clone()])
}
async fn get_storage(&self) -> Option<Storage> {
self.storage.clone()
async fn get_storage(&self) -> Option<Vec<Storage>> {
self.storage.clone().map(|s| vec![s])
}
async fn get_device_id(&self) -> Result<Option<String>> {

View File

@@ -31,7 +31,7 @@ const TYPE_OVERLAY_FS: &str = "overlay";
pub trait Rootfs: Send + Sync {
async fn get_guest_rootfs_path(&self) -> Result<String>;
async fn get_rootfs_mount(&self) -> Result<Vec<oci::Mount>>;
async fn get_storage(&self) -> Option<Storage>;
async fn get_storage(&self) -> Option<Vec<Storage>>;
async fn cleanup(&self, device_manager: &RwLock<DeviceManager>) -> Result<()>;
async fn get_device_id(&self) -> Result<Option<String>>;
}

View File

@@ -149,8 +149,8 @@ impl Rootfs for NydusRootfs {
Ok(vec![])
}
async fn get_storage(&self) -> Option<Storage> {
Some(self.rootfs.clone())
async fn get_storage(&self) -> Option<Vec<Storage>> {
Some(vec![self.rootfs.clone()])
}
async fn get_device_id(&self) -> Result<Option<String>> {

View File

@@ -73,7 +73,7 @@ impl Rootfs for ShareFsRootfs {
todo!()
}
async fn get_storage(&self) -> Option<Storage> {
async fn get_storage(&self) -> Option<Vec<Storage>> {
None
}

View File

@@ -15,6 +15,7 @@ use oci_spec::runtime as oci;
use serde_json;
use tokio::sync::RwLock;
use agent::Storage;
use hypervisor::device::device_manager::DeviceManager;
use kata_types::{
annotations,
@@ -184,8 +185,8 @@ impl super::Rootfs for VirtualVolume {
Ok(vec![])
}
async fn get_storage(&self) -> Option<agent::Storage> {
Some(self.storages[0].clone())
async fn get_storage(&self) -> Option<Vec<Storage>> {
Some(self.storages.clone())
}
async fn get_device_id(&self) -> Result<Option<String>> {

View File

@@ -167,8 +167,8 @@ impl Container {
);
let mut storages = vec![];
if let Some(storage) = rootfs.get_storage().await {
storages.push(storage);
if let Some(mut storage_list) = rootfs.get_storage().await {
storages.append(&mut storage_list);
}
inner.rootfs.push(rootfs);