[PATCH] qemu_tpm: Do not use persistent definition during pre-start checks

Martin Kletzander via Devel posted 1 patch 1 month, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/aaf851ba72fbf6875e888a8aa49817f4ec522061.1752844118.git.mkletzan@redhat.com
src/qemu/qemu_tpm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] qemu_tpm: Do not use persistent definition during pre-start checks
Posted by Martin Kletzander via Devel 1 month, 3 weeks ago
From: Martin Kletzander <mkletzan@redhat.com>

Commit 3451987fca7c used the persistent TPM Definition in both calls to
qemuTPMVirCommandSwtpmAddTPMState() but in one of the two cases it
might've been NULL and what's more, it is not the right definition which
should've been used.  Change that to @tpm which is the current
definition.  The other call does not have access to the current
definition and is only called during updating the profile.  But for the
sake of fewer future mistakes, keep the other one as is because there is
no issue with calling it that way and adding logic that just skips the
extra check on NULL could mistake someone in the future.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
 src/qemu/qemu_tpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c
index 5cb678df0eee..4c9445d72c39 100644
--- a/src/qemu/qemu_tpm.c
+++ b/src/qemu/qemu_tpm.c
@@ -852,7 +852,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm,
     virCommandAddArgFormat(cmd, "type=unixio,path=%s,mode=0600",
                            tpm->data.emulator.source->data.nix.path);
 
-    qemuTPMVirCommandSwtpmAddTPMState(cmd, &tpm->data.emulator, persistentTPMDef, cfg);
+    qemuTPMVirCommandSwtpmAddTPMState(cmd, &tpm->data.emulator, tpm, cfg);
 
     virCommandAddArg(cmd, "--log");
     if (tpm->data.emulator.debug != 0)
-- 
2.50.1
Re: [PATCH] qemu_tpm: Do not use persistent definition during pre-start checks
Posted by Pavel Hrdina via Devel 1 month, 3 weeks ago
On Fri, Jul 18, 2025 at 03:08:38PM +0200, Martin Kletzander wrote:
> From: Martin Kletzander <mkletzan@redhat.com>
> 
> Commit 3451987fca7c used the persistent TPM Definition in both calls to
> qemuTPMVirCommandSwtpmAddTPMState() but in one of the two cases it
> might've been NULL and what's more, it is not the right definition which
> should've been used.  Change that to @tpm which is the current
> definition.  The other call does not have access to the current
> definition and is only called during updating the profile.  But for the
> sake of fewer future mistakes, keep the other one as is because there is
> no issue with calling it that way and adding logic that just skips the
> extra check on NULL could mistake someone in the future.
> 
> Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
> ---
>  src/qemu/qemu_tpm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>