summaryrefslogtreecommitdiffstats
path: root/backends
diff options
context:
space:
mode:
authorRoss Lagerwall2022-08-01 16:25:25 +0200
committerStefan Berger2022-09-09 23:55:45 +0200
commita0bcec03761477371ff7c2e80dc07fff14222d92 (patch)
tree9bdd6968b7d5bfbc7c08ae16a3ba808999bd4e9b /backends
parentMerge tag 'pull-qapi-2022-09-07' of git://repo.or.cz/qemu/armbru into staging (diff)
downloadqemu-a0bcec03761477371ff7c2e80dc07fff14222d92.tar.gz
qemu-a0bcec03761477371ff7c2e80dc07fff14222d92.tar.xz
qemu-a0bcec03761477371ff7c2e80dc07fff14222d92.zip
tpm_emulator: Avoid double initialization during migration
When resuming after a migration, the backend sends CMD_INIT to the emulator from the startup callback, then it sends the migration state 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. Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Tested-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Diffstat (limited to 'backends')
-rw-r--r--backends/tpm/tpm_emulator.c10
1 files changed, 10 insertions, 0 deletions
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);
}