mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Add a feature flag for SEV-SNP support
This feature flag gates the development for SEV-SNP enabled guest. Also add a helper function to identify if SNP should be enabled for the guest. Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
3e1b0bc124
commit
5fd79571b7
@@ -78,6 +78,9 @@ pub enum Error {
|
||||
ParseNuma(OptionParserError),
|
||||
/// Failed validating configuration
|
||||
Validation(ValidationError),
|
||||
#[cfg(feature = "sev_snp")]
|
||||
/// Failed parsing SEV-SNP config
|
||||
ParseSevSnp(OptionParserError),
|
||||
#[cfg(feature = "tdx")]
|
||||
/// Failed parsing TDX config
|
||||
ParseTdx(OptionParserError),
|
||||
@@ -327,6 +330,8 @@ impl fmt::Display for Error {
|
||||
}
|
||||
ParseUserDevice(o) => write!(f, "Error parsing --user-device: {o}"),
|
||||
Validation(v) => write!(f, "Error validating configuration: {v}"),
|
||||
#[cfg(feature = "sev_snp")]
|
||||
ParseSevSnp(o) => write!(f, "Error parsing --sev_snp: {o}"),
|
||||
#[cfg(feature = "tdx")]
|
||||
ParseTdx(o) => write!(f, "Error parsing --tdx: {o}"),
|
||||
#[cfg(feature = "tdx")]
|
||||
@@ -518,6 +523,8 @@ impl PlatformConfig {
|
||||
.add("oem_strings");
|
||||
#[cfg(feature = "tdx")]
|
||||
parser.add("tdx");
|
||||
#[cfg(feature = "sev_snp")]
|
||||
parser.add("sev_snp");
|
||||
parser.parse(platform).map_err(Error::ParsePlatform)?;
|
||||
|
||||
let num_pci_segments: u16 = parser
|
||||
@@ -542,6 +549,12 @@ impl PlatformConfig {
|
||||
.map_err(Error::ParsePlatform)?
|
||||
.unwrap_or(Toggle(false))
|
||||
.0;
|
||||
#[cfg(feature = "sev_snp")]
|
||||
let sev_snp = parser
|
||||
.convert::<Toggle>("sev_snp")
|
||||
.map_err(Error::ParsePlatform)?
|
||||
.unwrap_or(Toggle(false))
|
||||
.0;
|
||||
Ok(PlatformConfig {
|
||||
num_pci_segments,
|
||||
iommu_segments,
|
||||
@@ -550,6 +563,8 @@ impl PlatformConfig {
|
||||
oem_strings,
|
||||
#[cfg(feature = "tdx")]
|
||||
tdx,
|
||||
#[cfg(feature = "sev_snp")]
|
||||
sev_snp,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2183,6 +2198,11 @@ impl VmConfig {
|
||||
pub fn is_tdx_enabled(&self) -> bool {
|
||||
self.platform.as_ref().map(|p| p.tdx).unwrap_or(false)
|
||||
}
|
||||
|
||||
#[cfg(feature = "sev_snp")]
|
||||
pub fn is_sev_snp_enabled(&self) -> bool {
|
||||
self.platform.as_ref().map(|p| p.sev_snp).unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for VmConfig {
|
||||
|
||||
@@ -89,6 +89,9 @@ pub struct PlatformConfig {
|
||||
#[cfg(feature = "tdx")]
|
||||
#[serde(default)]
|
||||
pub tdx: bool,
|
||||
#[cfg(feature = "sev_snp")]
|
||||
#[serde(default)]
|
||||
pub sev_snp: bool,
|
||||
}
|
||||
|
||||
impl Default for PlatformConfig {
|
||||
@@ -101,6 +104,8 @@ impl Default for PlatformConfig {
|
||||
oem_strings: None,
|
||||
#[cfg(feature = "tdx")]
|
||||
tdx: false,
|
||||
#[cfg(feature = "sev_snp")]
|
||||
sev_snp: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user