]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_tpm: Do async IO when starting swtpm emulator
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 21 Mar 2022 12:33:06 +0000 (13:33 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 28 Mar 2022 08:00:18 +0000 (10:00 +0200)
When vTPM is secured via virSecret libvirt passes the secret
value via an FD when swtpm is started (arguments --key and
--migration-key). The writing of the secret into the FDs is
handled via virCommand, specifically qemu_tpm calls
virCommandSetSendBuffer()) and then virCommandRunAsync() spawns a
thread to handle writing into the FD via
virCommandDoAsyncIOHelper. But the thread is not created unless
VIR_EXEC_ASYNC_IO flag is set, which it isn't. In order to fix
it, virCommandDoAsyncIO() must be called.

The credit goes to Marc-AndrĂ© Lureau
<marcandre.lureau@redhat.com> who has done all the debugging and
proposed fix in the bugzilla.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2064115
Fixes: a9c500d2b50c5c041a1bb6ae9724402cf1cec8fe
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_tpm.c

index 50f9caabf3d18881ec9781d1632698054eb4790f..56bccee1284253605146dadcd86303342caaf2ea 100644 (file)
@@ -899,6 +899,7 @@ qemuTPMEmulatorStart(virQEMUDriver *driver,
     if (!(pidfile = qemuTPMEmulatorPidFileBuildPath(cfg->swtpmStateDir, shortName)))
         return -1;
 
+    virCommandDoAsyncIO(cmd);
     virCommandDaemonize(cmd);
     virCommandSetPidFile(cmd, pidfile);
     virCommandSetErrorFD(cmd, &errfd);