]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_tpm: Try harder to create emulator state
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 21 Jul 2023 08:47:59 +0000 (10:47 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 21 Jul 2023 13:01:39 +0000 (15:01 +0200)
If a per-domain SWTPM state directory exists but is empty our
code still considers it a valid state and skips running
'swtpm_setup' (handled in qemuTPMEmulatorRunSetup()).
While we should not try to inspect individual files created by
swtpm, we can still consider empty folder as non-existent state.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/320
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_tpm.c

index 0b77ce2bc784923460d202b1cb63f1f2d53998cd..450f96ecfdf51037b875eaf6362ea666d58f1007 100644 (file)
@@ -186,7 +186,8 @@ qemuTPMEmulatorCreateStorage(virDomainTPMDef *tpm,
 
     *created = false;
 
-    if (!virFileExists(storagepath))
+    if (!virFileExists(storagepath) ||
+        virDirIsEmpty(storagepath, true) > 0)
         *created = true;
 
     if (virDirCreate(storagepath, 0700, swtpm_user, swtpm_group,