mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 20:24:31 +00:00
agent: move StorageDeviceGeneric from kata-types into agent
Move StorageDeviceGeneric from kata-types into agent, so we can refactor code later. Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
This commit is contained in:
parent
d848126b61
commit
3a3d77b3b5
@ -16,7 +16,7 @@ use std::{thread, time};
|
|||||||
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use kata_types::cpu::CpuSet;
|
use kata_types::cpu::CpuSet;
|
||||||
use kata_types::mount::{StorageDevice, StorageDeviceGeneric};
|
use kata_types::mount::StorageDevice;
|
||||||
use libc::pid_t;
|
use libc::pid_t;
|
||||||
use oci::{Hook, Hooks};
|
use oci::{Hook, Hooks};
|
||||||
use protocols::agent::OnlineCPUMemRequest;
|
use protocols::agent::OnlineCPUMemRequest;
|
||||||
@ -37,6 +37,7 @@ use crate::namespace::Namespace;
|
|||||||
use crate::netlink::Handle;
|
use crate::netlink::Handle;
|
||||||
use crate::network::Network;
|
use crate::network::Network;
|
||||||
use crate::pci;
|
use crate::pci;
|
||||||
|
use crate::storage::StorageDeviceGeneric;
|
||||||
use crate::uevent::{Uevent, UeventMatcher};
|
use crate::uevent::{Uevent, UeventMatcher};
|
||||||
use crate::watcher::BindWatcher;
|
use crate::watcher::BindWatcher;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::fmt::Formatter;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::os::unix::fs::{MetadataExt, PermissionsExt};
|
use std::os::unix::fs::{MetadataExt, PermissionsExt};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@ -12,9 +13,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use kata_sys_util::mount::{create_mount_destination, parse_mount_options};
|
use kata_sys_util::mount::{create_mount_destination, parse_mount_options};
|
||||||
use kata_types::mount::{
|
use kata_types::mount::{StorageDevice, StorageHandlerManager, KATA_SHAREDFS_GUEST_PREMOUNT_TAG};
|
||||||
StorageDevice, StorageDeviceGeneric, StorageHandlerManager, KATA_SHAREDFS_GUEST_PREMOUNT_TAG,
|
|
||||||
};
|
|
||||||
use nix::unistd::{Gid, Uid};
|
use nix::unistd::{Gid, Uid};
|
||||||
use protocols::agent::Storage;
|
use protocols::agent::Storage;
|
||||||
use protocols::types::FSGroupChangePolicy;
|
use protocols::types::FSGroupChangePolicy;
|
||||||
@ -55,6 +54,34 @@ pub struct StorageContext<'a> {
|
|||||||
sandbox: &'a Arc<Mutex<Sandbox>>,
|
sandbox: &'a Arc<Mutex<Sandbox>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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.
|
/// Trait object to handle storage device.
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
pub trait StorageHandler: Send + Sync {
|
pub trait StorageHandler: Send + Sync {
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
use anyhow::{anyhow, Context, Error, Result};
|
use anyhow::{anyhow, Context, Error, Result};
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fmt::Formatter;
|
|
||||||
use std::{collections::HashMap, fs, path::PathBuf};
|
use std::{collections::HashMap, fs, path::PathBuf};
|
||||||
|
|
||||||
/// Prefix to mark a volume as Kata special.
|
/// 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.
|
/// Trait object for storage device.
|
||||||
pub trait StorageDevice: Send + Sync {
|
pub trait StorageDevice: Send + Sync {
|
||||||
/// Path
|
/// Path
|
||||||
|
Loading…
Reference in New Issue
Block a user