Many methods merely want to know that the swtpm binaries have been found, and don't care about probing for capabilities. Even when starting a guest, the QEMU driver may not need the capabilities. Skipping probing ensures the VM startup path is as fast as possible when capabilities are not required. It also removes various error scenarios from the main init method. Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- src/util/virtpm.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/util/virtpm.c b/src/util/virtpm.c index 7e75c74d67..ec51c0efb3 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -310,14 +310,8 @@ virTPMEmulatorInit(void) return -1; } swtpmBinaries[i].path = g_steal_pointer(&path); - - if (swtpmBinaries[i].capsParse) { - swtpmBinaries[i].caps = virTPMGetCaps(swtpmBinaries[i].capsParse, - swtpmBinaries[i].path, - swtpmBinaries[i].parm); - if (!swtpmBinaries[i].caps) - return -1; - } + virBitmapFree(swtpmBinaries[i].caps); + swtpmBinaries[i].caps = NULL; } } @@ -334,7 +328,16 @@ virTPMBinaryGetCaps(virTPMBinary binary, if (virTPMEmulatorInit() < 0) goto cleanup; - ret = virBitmapIsBitSet(swtpmBinaries[binary].caps, cap); + + if (!swtpmBinaries[binary].caps && + swtpmBinaries[binary].capsParse) { + swtpmBinaries[binary].caps = virTPMGetCaps( + swtpmBinaries[binary].capsParse, + swtpmBinaries[binary].path, + swtpmBinaries[binary].parm); + } + if (swtpmBinaries[binary].caps) + ret = virBitmapIsBitSet(swtpmBinaries[binary].caps, cap); cleanup: virMutexUnlock(&swtpm_tools_lock); -- 2.33.1