vm start: only print tpm-related message if there is an instance

Otherwise, this can produce an undef warning and be misleading.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2021-10-27 08:49:37 +02:00 committed by Thomas Lamprecht
parent 25de70ae59
commit 23bee97d05

View File

@ -5453,8 +5453,10 @@ sub vm_start_nolock {
my $exitcode = run_command($cmd, %run_params);
if ($exitcode) {
warn "stopping swtpm instance (pid $tpmpid) due to QEMU startup error\n";
kill 'TERM', $tpmpid if $tpmpid;
if ($tpmpid) {
warn "stopping swtpm instance (pid $tpmpid) due to QEMU startup error\n";
kill 'TERM', $tpmpid;
}
die "QEMU exited with code $exitcode\n";
}
};