mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-26 23:38:31 +00:00
kata-ctl: add constants for direct-volume commands
added direct-volume mountinfo struct and constant path strings to kata-types Fixes #5341 Signed-off-by: Tingzhou Yuan <tzyuan15@bu.edu>
This commit is contained in:
parent
38a6bc570d
commit
cae78a6851
@ -5,7 +5,7 @@
|
||||
//
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use std::path::PathBuf;
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
/// Prefix to mark a volume as Kata special.
|
||||
pub const KATA_VOLUME_TYPE_PREFIX: &str = "kata:";
|
||||
@ -19,6 +19,12 @@ pub const KATA_EPHEMERAL_VOLUME_TYPE: &str = "ephemeral";
|
||||
/// KATA_HOST_DIR_TYPE use for host empty dir
|
||||
pub const KATA_HOST_DIR_VOLUME_TYPE: &str = "kata:hostdir";
|
||||
|
||||
/// KATA_MOUNT_INFO_FILE_NAME is used for the file that holds direct-volume mount info
|
||||
pub const KATA_MOUNT_INFO_FILE_NAME: &str = "mountInfo.json";
|
||||
|
||||
/// KATA_DIRECT_VOLUME_ROOT_PATH is the root path used for concatenating with the direct-volume mount info file path
|
||||
pub const KATA_DIRECT_VOLUME_ROOT_PATH: &str = "/run/kata-containers/shared/direct-volumes";
|
||||
|
||||
/// Information about a mount.
|
||||
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Mount {
|
||||
@ -49,6 +55,22 @@ impl Mount {
|
||||
}
|
||||
}
|
||||
|
||||
/// DirectVolumeMountInfo contains the information needed by Kata
|
||||
/// to consume a host block device and mount it as a filesystem inside the guest VM.
|
||||
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
|
||||
pub struct DirectVolumeMountInfo {
|
||||
/// The type of the volume (ie. block)
|
||||
pub volume_type: String,
|
||||
/// The device backing the volume.
|
||||
pub device: String,
|
||||
/// The filesystem type to be mounted on the volume.
|
||||
pub fs_type: String,
|
||||
/// Additional metadata to pass to the agent regarding this volume.
|
||||
pub metadata: HashMap<String, String>,
|
||||
/// Additional mount options.
|
||||
pub options: Vec<String>,
|
||||
}
|
||||
|
||||
/// Check whether a mount type is a marker for Kata specific volume.
|
||||
pub fn is_kata_special_volume(ty: &str) -> bool {
|
||||
ty.len() > KATA_VOLUME_TYPE_PREFIX.len() && ty.starts_with(KATA_VOLUME_TYPE_PREFIX)
|
||||
|
2453
src/tools/kata-ctl/Cargo.lock
generated
2453
src/tools/kata-ctl/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -22,8 +22,7 @@ nix = "0.25.0"
|
||||
strum = "0.24.1"
|
||||
strum_macros = "0.24.3"
|
||||
|
||||
runtimes = { path = "../../runtime-rs/crates/runtimes" }
|
||||
serde = "1.0.149"
|
||||
serde = { version = "1.0.149", features = ["derive"] }
|
||||
|
||||
[target.'cfg(target_arch = "s390x")'.dependencies]
|
||||
reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "native-tls"] }
|
||||
|
Loading…
Reference in New Issue
Block a user