mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
util: pull TPM capabilities probing out of main init method
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. Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
63c42ba1d1
commit
45f83e3a0b
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user