]> git.proxmox.com Git - qemu-server.git/commit - PVE/VZDump/QemuServer.pm
fix #3075: add TPM v1.2 and v2.0 support via swtpm
authorStefan Reiter <s.reiter@proxmox.com>
Mon, 4 Oct 2021 15:29:20 +0000 (17:29 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 5 Oct 2021 04:51:02 +0000 (06:51 +0200)
commitf9dde219f23108d7c8991ddb51c6be44cc9438b9
tree9ae734bb04ec1ea77d559659c7496d76630ad446
parentd2ceac56b54d3e89c4eca71607d114b6d7e0093c
fix #3075: add TPM v1.2 and v2.0 support via swtpm

Starts an instance of swtpm per VM in it's systemd scope, it will
terminate by itself if the VM exits, or be terminated manually if
startup fails.

Before first use, a TPM state is created via swtpm_setup. State is
stored in a 'tpmstate0' volume, treated much the same way as an efidisk.

It is migrated 'offline', the important part here is the creation of the
target volume, the actual data transfer happens via the QEMU device
state migration process.

Move-disk can only work offline, as the disk is not registered with
QEMU, so 'drive-mirror' wouldn't work. swtpm itself has no method of
moving a backing storage at runtime.

For backups, a bit of a workaround is necessary (this may later be
replaced by NBD support in swtpm): During the backup, we attach the
backing file of the TPM as a read-only drive to QEMU, so our backup
code can detect it as a block device and back it up as such, while
ensuring consistency with the rest of disk state ("snapshot" semantic).

The name for the ephemeral drive is specifically chosen as
'drive-tpmstate0-backup', diverging from our usual naming scheme with
the '-backup' suffix, to avoid it ever being treated as a regular drive
from the rest of the stack in case it gets left over after a backup for
some reason (shouldn't happen).

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
PVE/API2/Qemu.pm
PVE/QemuMigrate.pm
PVE/QemuServer.pm
PVE/QemuServer/Drive.pm
PVE/VZDump/QemuServer.pm