Merge pull request #6277 from openanolis/chao/add_is_tdx_enable

CC | Dragonball TDX: add is_tdx_enabled to identify tdx VM type
This commit is contained in:
Fabiano Fidêncio 2023-02-16 06:37:10 +01:00 committed by GitHub
commit ad889489a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -83,6 +83,11 @@ impl InstanceInfo {
confidential_vm_type: None,
}
}
/// return true if VM confidential type is TDX
pub fn is_tdx_enabled(&self) -> bool {
matches!(self.confidential_vm_type, Some(ConfidentialVmType::TDX))
}
}
impl Default for InstanceInfo {

View File

@ -350,6 +350,15 @@ impl Vm {
instance_state == InstanceState::Running
}
/// return true if VM confidential type is TDX
pub fn is_tdx_enabled(&self) -> bool {
let shared_info = self
.shared_info()
.read()
.expect("failed to get instance state, because shared info is poisoned lock");
shared_info.is_tdx_enabled()
}
/// Save VM instance exit state
pub fn vm_exit(&self, exit_code: i32) {
if let Ok(mut info) = self.shared_info.write() {