]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: tpm: Conditionally create storage on incoming migration
authorStefan Berger <stefanb@linux.ibm.com>
Mon, 24 Oct 2022 10:28:44 +0000 (06:28 -0400)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 9 Nov 2022 11:26:27 +0000 (12:26 +0100)
Do not create storage if the TPM state files are on shared storage and
there's an incoming migration since in this case the storage directory
must already exist. Also do not run swtpm_setup in this case.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_tpm.c

index 40bf4847e3e1aced14280fdbc93fe8c7cc43dad7..2d86e13b2ac448b905e976f10144311d7724a789 100644 (file)
@@ -556,11 +556,20 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm,
     int pwdfile_fd = -1;
     int migpwdfile_fd = -1;
     const unsigned char *secretuuid = NULL;
+    bool create_storage = true;
 
     if (!swtpm)
         return NULL;
 
-    if (qemuTPMEmulatorCreateStorage(tpm, &created, swtpm_user, swtpm_group) < 0)
+    /* Do not create storage and run swtpm_setup on incoming migration over
+     * shared storage
+     */
+    if (incomingMigration &&
+        virFileIsSharedFS(tpm->data.emulator.storagepath) == 1)
+        create_storage = false;
+
+    if (create_storage &&
+        qemuTPMEmulatorCreateStorage(tpm, &created, swtpm_user, swtpm_group) < 0)
         return NULL;
 
     if (tpm->data.emulator.hassecretuuid)