qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] tpm_emulator: Avoid double initialization during migration


From: Stefan Berger
Subject: Re: [PATCH] tpm_emulator: Avoid double initialization during migration
Date: Mon, 8 Aug 2022 13:49:49 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0



On 8/1/22 10:27, Ross Lagerwall via wrote:
When resuming after a migration, the backend sends CMD_INIT to the
emulator from the startup callback, then it sends the migration state

This startup hook is called upon TIS/CRB device reset, so this is likely called before the device state has been received.

from the vmstate to the emulator, then it sends CMD_INIT again. Skip the
first CMD_INIT during a migration to avoid initializing the TPM twice.

Ok, that's sufficient to start it up once all the state has been received.


Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>


Tested-by: Stefan Berger <stefanb@linux.ibm.com>

---
  backends/tpm/tpm_emulator.c | 10 ++++++++++
  1 file changed, 10 insertions(+)

diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c
index 87d061e9bb..9b50c5b3e2 100644
--- a/backends/tpm/tpm_emulator.c
+++ b/backends/tpm/tpm_emulator.c
@@ -32,6 +32,7 @@
  #include "qemu/sockets.h"
  #include "qemu/lockable.h"
  #include "io/channel-socket.h"
+#include "sysemu/runstate.h"
  #include "sysemu/tpm_backend.h"
  #include "sysemu/tpm_util.h"
  #include "tpm_int.h"
@@ -383,6 +384,15 @@ err_exit:

  static int tpm_emulator_startup_tpm(TPMBackend *tb, size_t buffersize)
  {
+    /* TPM startup will be done from post_load hook */
+    if (runstate_check(RUN_STATE_INMIGRATE)) {
+        if (buffersize != 0) {
+            return tpm_emulator_set_buffer_size(tb, buffersize, NULL);
+        }
+
+        return 0;
+    }
+
      return tpm_emulator_startup_tpm_resume(tb, buffersize, false);
  }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]