[pve-devel] [PATCH v3 qemu-server] fix #3963: Skip TPM startup for template VMs

Filip Schauer f.schauer at proxmox.com
Wed Aug 9 17:24:18 CEST 2023


Skip the software TPM startup when starting a template VM for performing
a backup. This fixes an error that occurs when the TPM state disk is
write-protected.

Signed-off-by: Filip Schauer <f.schauer at proxmox.com>
---
Changes since v2:
* Do not add the TPM to the command line arguments when VM is a template

 PVE/QemuServer.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 484bc7f..aa98d5f 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3823,7 +3823,9 @@ sub config_to_command {
 	push @$devices, @$audio_devs;
     }
 
-    add_tpm_device($vmid, $devices, $conf);
+    if (!PVE::QemuConfig->is_template($conf)) {
+	add_tpm_device($vmid, $devices, $conf);
+    }
 
     my $sockets = 1;
     $sockets = $conf->{smp} if $conf->{smp}; # old style - no longer iused
@@ -5923,7 +5925,7 @@ sub vm_start_nolock {
 	    PVE::Systemd::enter_systemd_scope($vmid, "Proxmox VE VM $vmid", %systemd_properties);
 
 	    my $tpmpid;
-	    if (my $tpm = $conf->{tpmstate0}) {
+	    if ((my $tpm = $conf->{tpmstate0}) && !PVE::QemuConfig->is_template($conf)) {
 		# start the TPM emulator so QEMU can connect on start
 		$tpmpid = start_swtpm($storecfg, $vmid, $tpm, $migratedfrom);
 	    }
-- 
2.39.2






More information about the pve-devel mailing list