diff --git a/src/agent/src/sandbox.rs b/src/agent/src/sandbox.rs index aac0f81584..ebc38a288b 100644 --- a/src/agent/src/sandbox.rs +++ b/src/agent/src/sandbox.rs @@ -16,7 +16,7 @@ use std::{thread, time}; use anyhow::{anyhow, Context, Result}; use kata_types::cpu::CpuSet; -use kata_types::mount::{StorageDevice, StorageDeviceGeneric}; +use kata_types::mount::StorageDevice; use libc::pid_t; use oci::{Hook, Hooks}; use protocols::agent::OnlineCPUMemRequest; @@ -37,6 +37,7 @@ use crate::namespace::Namespace; use crate::netlink::Handle; use crate::network::Network; use crate::pci; +use crate::storage::StorageDeviceGeneric; use crate::uevent::{Uevent, UeventMatcher}; use crate::watcher::BindWatcher; diff --git a/src/agent/src/storage/mod.rs b/src/agent/src/storage/mod.rs index 80cc081faa..decfc1374a 100644 --- a/src/agent/src/storage/mod.rs +++ b/src/agent/src/storage/mod.rs @@ -5,6 +5,7 @@ // use std::collections::HashMap; +use std::fmt::Formatter; use std::fs; use std::os::unix::fs::{MetadataExt, PermissionsExt}; use std::path::Path; @@ -12,9 +13,7 @@ use std::sync::Arc; use anyhow::{anyhow, Context, Result}; use kata_sys_util::mount::{create_mount_destination, parse_mount_options}; -use kata_types::mount::{ - StorageDevice, StorageDeviceGeneric, StorageHandlerManager, KATA_SHAREDFS_GUEST_PREMOUNT_TAG, -}; +use kata_types::mount::{StorageDevice, StorageHandlerManager, KATA_SHAREDFS_GUEST_PREMOUNT_TAG}; use nix::unistd::{Gid, Uid}; use protocols::agent::Storage; use protocols::types::FSGroupChangePolicy; @@ -55,6 +54,34 @@ pub struct StorageContext<'a> { sandbox: &'a Arc>, } +/// An implementation of generic storage device. +pub struct StorageDeviceGeneric { + path: String, +} + +impl std::fmt::Debug for StorageDeviceGeneric { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("StorageDeviceGeneric") + .field("path", &self.path) + .finish() + } +} + +impl StorageDeviceGeneric { + /// Create a new instance of `StorageStateCommon`. + pub fn new(path: String) -> Self { + StorageDeviceGeneric { path } + } +} + +impl StorageDevice for StorageDeviceGeneric { + fn path(&self) -> &str { + &self.path + } + + fn cleanup(&self) {} +} + /// Trait object to handle storage device. #[async_trait::async_trait] pub trait StorageHandler: Send + Sync { diff --git a/src/libs/kata-types/src/mount.rs b/src/libs/kata-types/src/mount.rs index 521a24a4e7..04ec1fc884 100644 --- a/src/libs/kata-types/src/mount.rs +++ b/src/libs/kata-types/src/mount.rs @@ -7,7 +7,6 @@ use anyhow::{anyhow, Context, Error, Result}; use std::collections::hash_map::Entry; use std::convert::TryFrom; -use std::fmt::Formatter; use std::{collections::HashMap, fs, path::PathBuf}; /// Prefix to mark a volume as Kata special. @@ -429,34 +428,6 @@ impl TryFrom<&NydusExtraOptions> for KataVirtualVolume { } } -/// An implementation of generic storage device. -pub struct StorageDeviceGeneric { - path: String, -} - -impl std::fmt::Debug for StorageDeviceGeneric { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.debug_struct("StorageState") - .field("path", &self.path) - .finish() - } -} - -impl StorageDeviceGeneric { - /// Create a new instance of `StorageStateCommon`. - pub fn new(path: String) -> Self { - StorageDeviceGeneric { path } - } -} - -impl StorageDevice for StorageDeviceGeneric { - fn path(&self) -> &str { - &self.path - } - - fn cleanup(&self) {} -} - /// Trait object for storage device. pub trait StorageDevice: Send + Sync { /// Path