render / rpms / libvirt

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