mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
testutilsqemu: Fake TPM versions
Because of v8.5.0-rc1~25 we are already faking TPM support for domaincaps. Might as well fake supported TPM versions. The swtpm binary supports both TPM versions since its first release, but pretend it isn't the case. For QEMU-5.2 and older pretend only TPM-1.2 is available, QEMU-6.* has both TPM-1.2 and TPM-2.0 and QEMU-7.0 and newer has only TPM-2.0 available. This way, domaincaps are more dispersed. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
This commit is contained in:
parent
a6c1d061a5
commit
1445f62fce
@ -198,6 +198,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -217,6 +217,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -198,6 +198,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -198,6 +198,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -217,6 +217,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -198,6 +198,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -204,6 +204,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -220,6 +220,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -204,6 +204,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -212,6 +212,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -227,6 +227,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -132,6 +132,9 @@
|
||||
<value>spapr-tpm-proxy</value>
|
||||
</enum>
|
||||
<enum name='backendModel'/>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -212,6 +212,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -214,6 +214,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -229,6 +229,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -173,6 +173,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -171,6 +171,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -138,6 +138,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -214,6 +214,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -215,6 +215,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -229,6 +229,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -215,6 +215,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -215,6 +215,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -229,6 +229,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -173,6 +173,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -171,6 +171,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -138,6 +138,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -215,6 +215,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -216,6 +216,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -230,6 +230,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -174,6 +174,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -172,6 +172,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -216,6 +216,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -217,6 +217,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -230,6 +230,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -217,6 +217,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -217,6 +217,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -231,6 +231,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -176,6 +176,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -174,6 +174,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -136,6 +136,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -217,6 +217,10 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>1.2</value>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -219,6 +219,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -233,6 +233,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -176,6 +176,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -174,6 +174,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -138,6 +138,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -219,6 +219,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -218,6 +218,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -231,6 +231,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -218,6 +218,9 @@
|
||||
<value>passthrough</value>
|
||||
<value>emulator</value>
|
||||
</enum>
|
||||
<enum name='backendVersion'>
|
||||
<value>2.0</value>
|
||||
</enum>
|
||||
</tpm>
|
||||
</devices>
|
||||
<features>
|
||||
|
@ -252,6 +252,7 @@ doTestQemuInternal(const char *version,
|
||||
g_autofree char *name = NULL;
|
||||
g_autofree char *capsName = NULL;
|
||||
g_autofree char *emulator = NULL;
|
||||
int rc;
|
||||
|
||||
name = g_strdup_printf("qemu_%s%s%s%s.%s",
|
||||
version,
|
||||
@ -274,7 +275,21 @@ doTestQemuInternal(const char *version,
|
||||
};
|
||||
VIR_WARNINGS_RESET
|
||||
|
||||
if (virTestRun(name, test_virDomainCapsFormat, &data) < 0)
|
||||
if (STRPREFIX(version, "3.") ||
|
||||
STRPREFIX(version, "4.") ||
|
||||
STRPREFIX(version, "5.")) {
|
||||
g_setenv(TEST_TPM_ENV_VAR, TPM_VER_1_2, true);
|
||||
} else if (STRPREFIX(version, "6.")) {
|
||||
g_setenv(TEST_TPM_ENV_VAR, TPM_VER_1_2 TPM_VER_2_0, true);
|
||||
} else {
|
||||
g_setenv(TEST_TPM_ENV_VAR, TPM_VER_2_0, true);
|
||||
}
|
||||
|
||||
rc = virTestRun(name, test_virDomainCapsFormat, &data);
|
||||
|
||||
g_unsetenv(TEST_TPM_ENV_VAR);
|
||||
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
@ -146,16 +146,25 @@ bool virTPMHasSwtpm(void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
virTPMSwtpmSetupCapsGet(virTPMSwtpmSetupFeature cap)
|
||||
{
|
||||
const char *tpmver = getenv(TEST_TPM_ENV_VAR);
|
||||
|
||||
switch (cap) {
|
||||
case VIR_TPM_SWTPM_SETUP_FEATURE_TPM_1_2:
|
||||
if (!tpmver || (tpmver && strstr(tpmver, TPM_VER_1_2)))
|
||||
return true;
|
||||
break;
|
||||
case VIR_TPM_SWTPM_SETUP_FEATURE_TPM_2_0:
|
||||
if (!tpmver || (tpmver && strstr(tpmver, TPM_VER_2_0)))
|
||||
return true;
|
||||
break;
|
||||
case VIR_TPM_SWTPM_SETUP_FEATURE_CMDARG_PWDFILE_FD:
|
||||
case VIR_TPM_SWTPM_SETUP_FEATURE_CMDARG_CREATE_CONFIG_FILES:
|
||||
case VIR_TPM_SWTPM_SETUP_FEATURE_TPM12_NOT_NEED_ROOT:
|
||||
case VIR_TPM_SWTPM_SETUP_FEATURE_CMDARG_RECONFIGURE_PCR_BANKS:
|
||||
case VIR_TPM_SWTPM_SETUP_FEATURE_TPM_1_2:
|
||||
case VIR_TPM_SWTPM_SETUP_FEATURE_TPM_2_0:
|
||||
case VIR_TPM_SWTPM_SETUP_FEATURE_LAST:
|
||||
break;
|
||||
}
|
||||
|
@ -25,6 +25,9 @@
|
||||
# include "qemu/qemu_conf.h"
|
||||
|
||||
# define TEST_QEMU_CAPS_PATH abs_srcdir "/qemucapabilitiesdata"
|
||||
# define TEST_TPM_ENV_VAR "VIR_TEST_MOCK_FAKE_TPM_VERSION"
|
||||
# define TPM_VER_1_2 "1.2"
|
||||
# define TPM_VER_2_0 "2.0"
|
||||
|
||||
enum {
|
||||
GIC_NONE = 0,
|
||||
|
Loading…
Reference in New Issue
Block a user