render / rpms / libvirt

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