vmspawn: only add to cmdline if tpm was started

This commit is contained in:
Sam Leonard
2024-02-28 22:05:33 +01:00
committed by Lennart Poettering
parent 5b97957376
commit eb77d24baa
+4 -2
View File
@@ -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)