<div dir="ltr"><div dir="ltr">Hi<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 21, 2022 at 6:59 PM Michal Privoznik <<a href="mailto:mprivozn@redhat.com">mprivozn@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">When vTPM is secured via virSecret libvirt passes the secret<br>
value via an FD when swtpm is started (arguments --key and<br>
--migration-key). The writing of the secret into the FDs is<br>
handled via virCommand, specifically qemu_tpm calls<br>
virCommandSetSendBuffer()) and then virCommandRunAsync() spawns a<br>
thread to handle writing into the FD via<br>
virCommandDoAsyncIOHelper. But the thread is not created unless<br>
VIR_EXEC_ASYNC_IO flag is set, which it isn't. In order to fix<br>
it, virCommandDoAsyncIO() must be called.<br>
<br>
The credit goes to Marc-André Lureau<br>
<<a href="mailto:marcandre.lureau@redhat.com" target="_blank">marcandre.lureau@redhat.com</a>> who has done all the debugging and<br>
proposed fix in the bugzilla.<br></blockquote><div><br></div><div>(thanks for the credit :)</div><div><br></div><div>Wouldn't it make sense to return an error if SendBuffers is used without AsyncIO then? Or just enable AsyncIO as necessary? (beware, I am not very familiar with virCommand API. I don't know what this would imply)</div><div><br></div><div>Also it would be nice to cover that "behaviour" in a test (even better if we could cover the swtpm setup & start handling too, although I realize this is more work!)<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Resolves: <a href="https://bugzilla.redhat.com/show_bug.cgi?id=2064115" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/show_bug.cgi?id=2064115</a><br>
Fixes: a9c500d2b50c5c041a1bb6ae9724402cf1cec8fe<br>
Signed-off-by: Michal Privoznik <<a href="mailto:mprivozn@redhat.com" target="_blank">mprivozn@redhat.com</a>><br>
---<br>
 src/qemu/qemu_tpm.c | 1 +<br>
 1 file changed, 1 insertion(+)<br>
<br>
diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c<br>
index 50f9caabf3..56bccee128 100644<br>
--- a/src/qemu/qemu_tpm.c<br>
+++ b/src/qemu/qemu_tpm.c<br>
@@ -899,6 +899,7 @@ qemuTPMEmulatorStart(virQEMUDriver *driver,<br>
     if (!(pidfile = qemuTPMEmulatorPidFileBuildPath(cfg->swtpmStateDir, shortName)))<br>
         return -1;<br>
<br>
+    virCommandDoAsyncIO(cmd);<br>
     virCommandDaemonize(cmd);<br>
     virCommandSetPidFile(cmd, pidfile);<br>
     virCommandSetErrorFD(cmd, &errfd);<br>
-- <br>
2.34.1<br>
<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">Marc-André Lureau<br></div></div>