3a9410
From 87b0f241db1eba0e9db1fd233c5ab8a8d0115979 Mon Sep 17 00:00:00 2001
3a9410
Message-Id: <87b0f241db1eba0e9db1fd233c5ab8a8d0115979@dist-git>
3a9410
From: Michal Privoznik <mprivozn@redhat.com>
3a9410
Date: Mon, 21 Mar 2022 13:33:06 +0100
3a9410
Subject: [PATCH] qemu_tpm: Do async IO when starting swtpm emulator
3a9410
MIME-Version: 1.0
3a9410
Content-Type: text/plain; charset=UTF-8
3a9410
Content-Transfer-Encoding: 8bit
3a9410
3a9410
When vTPM is secured via virSecret libvirt passes the secret
3a9410
value via an FD when swtpm is started (arguments --key and
3a9410
--migration-key). The writing of the secret into the FDs is
3a9410
handled via virCommand, specifically qemu_tpm calls
3a9410
virCommandSetSendBuffer()) and then virCommandRunAsync() spawns a
3a9410
thread to handle writing into the FD via
3a9410
virCommandDoAsyncIOHelper. But the thread is not created unless
3a9410
VIR_EXEC_ASYNC_IO flag is set, which it isn't. In order to fix
3a9410
it, virCommandDoAsyncIO() must be called.
3a9410
3a9410
The credit goes to Marc-André Lureau
3a9410
<marcandre.lureau@redhat.com> who has done all the debugging and
3a9410
proposed fix in the bugzilla.
3a9410
3a9410
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2064115
3a9410
Fixes: a9c500d2b50c5c041a1bb6ae9724402cf1cec8fe
3a9410
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
3a9410
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
3a9410
(cherry picked from commit 4d7bb0177a33c4e90fd001edfe27bc030354d875)
3a9410
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2152188
3a9410
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
3a9410
---
3a9410
 src/qemu/qemu_tpm.c | 1 +
3a9410
 1 file changed, 1 insertion(+)
3a9410
3a9410
diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c
3a9410
index 9c5d1ffed4..29dcb2ac0f 100644
3a9410
--- a/src/qemu/qemu_tpm.c
3a9410
+++ b/src/qemu/qemu_tpm.c
3a9410
@@ -923,6 +923,7 @@ qemuExtTPMStartEmulator(virQEMUDriver *driver,
3a9410
     if (!(pidfile = qemuTPMEmulatorCreatePidFilename(cfg->swtpmStateDir, shortName)))
3a9410
         return -1;
3a9410
 
3a9410
+    virCommandDoAsyncIO(cmd);
3a9410
     virCommandDaemonize(cmd);
3a9410
     virCommandSetPidFile(cmd, pidfile);
3a9410
     virCommandSetErrorFD(cmd, &errfd);
3a9410
-- 
3a9410
2.39.0
3a9410