提交 657365e7 编写于 作者: P Paulo de Rezende Pinatti 提交者: Erik Skultety

qemu: Check if AMD secure guest support is enabled

Implement secure guest check for AMD SEV (Secure Encrypted
Virtualization) in order to invalidate the qemu capabilities
cache in case the availability of the feature changed.

For AMD SEV the verification consists of:
 - checking if /sys/module/kvm_amd/parameters/sev contains the
   value '1': meaning SEV is enabled in the host kernel;
 - checking if /dev/sev exists
Signed-off-by: NPaulo de Rezende Pinatti <ppinatti@linux.ibm.com>
Signed-off-by: NBoris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: NBjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 b611b620
...@@ -4715,6 +4715,27 @@ virQEMUCapsKVMSupportsSecureGuestS390(void) ...@@ -4715,6 +4715,27 @@ virQEMUCapsKVMSupportsSecureGuestS390(void)
} }
/*
* Check whether AMD Secure Encrypted Virtualization (x86) is enabled
*/
static bool
virQEMUCapsKVMSupportsSecureGuestAMD(void)
{
g_autofree char *modValue = NULL;
if (virFileReadValueString(&modValue, "/sys/module/kvm_amd/parameters/sev") < 0)
return false;
if (modValue[0] != '1')
return false;
if (virFileExists(QEMU_DEV_SEV))
return true;
return false;
}
/* /*
* Check whether the secure guest functionality is enabled. * Check whether the secure guest functionality is enabled.
* See the specific architecture function for details on the verifications made. * See the specific architecture function for details on the verifications made.
...@@ -4726,6 +4747,10 @@ virQEMUCapsKVMSupportsSecureGuest(void) ...@@ -4726,6 +4747,10 @@ virQEMUCapsKVMSupportsSecureGuest(void)
if (ARCH_IS_S390(arch)) if (ARCH_IS_S390(arch))
return virQEMUCapsKVMSupportsSecureGuestS390(); return virQEMUCapsKVMSupportsSecureGuestS390();
if (ARCH_IS_X86(arch))
return virQEMUCapsKVMSupportsSecureGuestAMD();
return false; return false;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册