]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: tpm: Enable creation of certs for TPM 1.2 in non-privileged mode
authorStefan Berger <stefanb@linux.ibm.com>
Sat, 30 Oct 2021 04:01:37 +0000 (00:01 -0400)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 1 Nov 2021 14:51:05 +0000 (15:51 +0100)
When 'swtpm_setup --print-capabilities' shows the 'tpm12-not-need-root'
flag, then it is possible to create certificates for the TPM 1.2 also
in non-privileged mode since swtpm_setup doesn't need tcsd anymore.
Check for this flag and create the certificates if this flag is found.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_tpm.c
src/util/virtpm.c
src/util/virtpm.h

index e1b08a66c5da1e31eaddd6882de95a89ce1d29e0..5a05273100668ef5dd8515d1eedf89e88ea0ddeb 100644 (file)
@@ -463,11 +463,13 @@ qemuTPMEmulatorRunSetup(const char *storagepath,
     if (!swtpm_setup)
         return -1;
 
-    if (!privileged && tpmversion == VIR_DOMAIN_TPM_VERSION_1_2)
+    if (!privileged && tpmversion == VIR_DOMAIN_TPM_VERSION_1_2 &&
+        !virTPMSwtpmSetupCapsGet(VIR_TPM_SWTPM_SETUP_FEATURE_TPM12_NOT_NEED_ROOT)) {
         return virFileWriteStr(logfile,
                                _("Did not create EK and certificates since "
                                  "this requires privileged mode for a "
                                  "TPM 1.2\n"), 0600);
+    }
 
     if (!privileged && qemuTPMCreateConfigFiles(swtpm_setup) < 0)
         return -1;
index 0f50de866c32ff8ded539627a2df9e42b0b0aa1e..40d9272e66473c844355638b951533704d640396 100644 (file)
@@ -46,6 +46,7 @@ VIR_ENUM_IMPL(virTPMSwtpmSetupFeature,
               VIR_TPM_SWTPM_SETUP_FEATURE_LAST,
               "cmdarg-pwdfile-fd",
               "cmdarg-create-config-files",
+              "tpm12-not-need-root",
 );
 
 /**
index 3bb03b3b335ca428c29f8214d51613452d69c17c..b75eb84f310d52d7230ec181c93719f9c2ee6ab7 100644 (file)
@@ -39,6 +39,7 @@ typedef enum {
 typedef enum {
     VIR_TPM_SWTPM_SETUP_FEATURE_CMDARG_PWDFILE_FD,
     VIR_TPM_SWTPM_SETUP_FEATURE_CMDARG_CREATE_CONFIG_FILES,
+    VIR_TPM_SWTPM_SETUP_FEATURE_TPM12_NOT_NEED_ROOT,
 
     VIR_TPM_SWTPM_SETUP_FEATURE_LAST
 } virTPMSwtpmSetupFeature;