From: Sam Leonard Date: Wed, 28 Feb 2024 17:39:05 +0000 (+0000) Subject: vmspawn: only add to cmdline if tpm was started X-Git-Tag: v256-rc1~704 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb77d24baa64a9b35858366e7b83709496544c43;p=thirdparty%2Fsystemd.git vmspawn: only add to cmdline if tpm was started --- diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c index ce7f1ef2e3e..5473d1464cb 100644 --- a/src/vmspawn/vmspawn.c +++ b/src/vmspawn/vmspawn.c @@ -1560,8 +1560,6 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) { _cleanup_free_ char *tpm_state_tempdir = NULL; if (swtpm) { - _cleanup_free_ char *escaped_state_dir = NULL; - r = start_tpm(bus, trans_scope, swtpm, &tpm_state_tempdir); if (r < 0) { /* only bail if the user asked for a tpm */ @@ -1569,6 +1567,10 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) { return log_error_errno(r, "Failed to start tpm: %m"); log_debug_errno(r, "Failed to start tpm, ignoring: %m"); } + } + + if (tpm_state_tempdir) { + _cleanup_free_ char *escaped_state_dir = NULL; escaped_state_dir = escape_qemu_value(tpm_state_tempdir); if (!escaped_state_dir)