runtime-rs: Add guest protection to hypervisor state

Store guest-protection used while storing the state of the hypervisor.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
Archana Shinde 2023-12-19 20:57:51 -08:00 committed by Archana Shinde
parent cf74166d75
commit a5f0b92bca
5 changed files with 13 additions and 7 deletions

9
src/libs/Cargo.lock generated
View File

@ -701,6 +701,7 @@ dependencies = [
"once_cell", "once_cell",
"rand", "rand",
"safe-path", "safe-path",
"serde",
"serde_json", "serde_json",
"serial_test", "serial_test",
"slog", "slog",
@ -1384,9 +1385,9 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.136" version = "1.0.147"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
@ -1423,9 +1424,9 @@ checksum = "794e44574226fc701e3be5c651feb7939038fc67fb73f6f4dd5c4ba90fd3be70"
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.136" version = "1.0.147"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@ -21,6 +21,7 @@ lazy_static = "1.4.0"
libc = "0.2.100" libc = "0.2.100"
nix = "0.24.2" nix = "0.24.2"
once_cell = "1.9.0" once_cell = "1.9.0"
serde = { version = "1.0.138", features = ["derive"] }
serde_json = "1.0.73" serde_json = "1.0.73"
slog = "2.5.2" slog = "2.5.2"
slog-scope = "4.4.0" slog-scope = "4.4.0"

View File

@ -12,6 +12,7 @@ use std::fmt;
use std::path::Path; use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;
use thiserror::Error; use thiserror::Error;
use serde::{Deserialize, Serialize};
#[cfg(any(target_arch = "s390x", target_arch = "powerpc64le"))] #[cfg(any(target_arch = "s390x", target_arch = "powerpc64le"))]
use nix::unistd::Uid; use nix::unistd::Uid;
@ -19,14 +20,14 @@ use nix::unistd::Uid;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use std::fs; use std::fs;
#[derive(Debug, Clone, PartialEq, Eq, Default)] #[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct TDXDetails { pub struct TDXDetails {
pub major_version: u32, pub major_version: u32,
pub minor_version: u32, pub minor_version: u32,
} }
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Debug, Clone, PartialEq, Default)] #[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub enum GuestProtection { pub enum GuestProtection {
#[default] #[default]
NoProtection, NoProtection,

View File

@ -1804,6 +1804,7 @@ dependencies = [
"once_cell", "once_cell",
"rand 0.8.5", "rand 0.8.5",
"safe-path 0.1.0", "safe-path 0.1.0",
"serde",
"serde_json", "serde_json",
"slog", "slog",
"slog-scope", "slog-scope",

View File

@ -5,9 +5,9 @@
// //
use crate::HypervisorConfig; use crate::HypervisorConfig;
use kata_sys_util::protection::GuestProtection;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashSet; use std::collections::HashSet;
#[derive(Serialize, Deserialize, Default, Clone, Debug)] #[derive(Serialize, Deserialize, Default, Clone, Debug)]
pub struct HypervisorState { pub struct HypervisorState {
// Type of hypervisor, E.g. dragonball/qemu/firecracker/acrn. // Type of hypervisor, E.g. dragonball/qemu/firecracker/acrn.
@ -34,4 +34,6 @@ pub struct HypervisorState {
pub cached_block_devices: HashSet<String>, pub cached_block_devices: HashSet<String>,
pub virtiofs_daemon_pid: i32, pub virtiofs_daemon_pid: i32,
pub passfd_listener_port: Option<u32>, pub passfd_listener_port: Option<u32>,
/// guest protection
pub guest_protection_to_use: GuestProtection,
} }