From 6c3ef66cc6d60d35e86206fd7b78178c4d0cbb88 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Fri, 21 Jul 2023 10:47:59 +0200 Subject: [PATCH] qemu_tpm: Try harder to create emulator state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- src/qemu/qemu_tpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 0b77ce2bc7..450f96ecfd 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -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,