mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-04-10 22:12:35 +00:00
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:
@@ -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>> {
|
||||
|
||||
@@ -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>>;
|
||||
}
|
||||
|
||||
@@ -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>> {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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>> {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user