nova/nova/tests/unit/api/openstack
Stephen Finucane eb819c8c63 Add support for resize and cold migration of emulated TPM files
When using emulated TPM, libvirt will store the persistent TPM data
under '/var/lib/libvirt/swtpm/<instance_uuid>' which is owned by the
"tss" or "root" user depending how libvirt is configured (the parent
directory, '/var/lib/libvirt/swtpm' is always owned by root). When doing
a resize or a cold migration between nodes, this data needs to be copied
to the other node to ensure that the TPM data is not lost.  Libvirt
won't do this automatically for us since cold migrations, or offline
migrations in libvirt lingo, do not currently support "copying
non-shared storage or other file based storages", which includes the
vTPM device [1].

To complicate things further, even if migration/resize is supported,
only the user that nova-compute runs as is guaranteed to be able to have
SSH keys set up for passwordless access, and it's only guaranteed to be
able to copy files to the instance directory on the dest node.

The solution is to have nova (via privsep) copy the TPM files into the
local instance directory on the source and changes the ownership. This
is handled through an additional call in 'migrate_disk_and_power_off'.
As itself, nova then copies them into the instance directory on the
dest. Nova then (once again, via privsep) changes the ownership back and
moves the files to where libvirt expects to find them. This second step
is handled by 'finish_migration'. Confirming the resize will result in
the original TPM data at '/var/lib/libvirt/swtpm' being deleted by
libvirt and the copied TPM data in the instance data being cleaned up by
nova (via 'confirm_migration'), while reverting it will result on the
same on the host.

Part of blueprint add-emulated-virtual-tpm

[1] https://libvirt.org/migration.html#offline

Change-Id: I9b053919bb499c308912c8c9bff4c1fc396c1193
Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
Co-authored-by: Stephen Finucane <stephenfin@redhat.com>
2020-09-08 09:58:21 +01:00
..
compute Add support for resize and cold migration of emulated TPM files 2020-09-08 09:58:21 +01:00
__init__.py
common.py [python3] Webob request body should be bytes 2015-12-28 13:51:29 -05:00
fakes.py Allow versioned discovery unauthenticated 2020-04-03 21:24:28 +00:00
test_api_version_request.py Replace 'fake' with a real project ID 2019-09-30 14:40:20 +09:00
test_auth.py Noauth should also use request_id from compute_req_id.py 2018-04-04 14:21:01 -04:00
test_common.py nova-net: Remove layer of indirection in 'nova.network' 2020-01-15 14:57:49 +00:00
test_faults.py [Py34] api.openstack.test_faults.TestFaultWrapper 2015-12-10 20:56:42 +00:00
test_legacy_v2_compatible_wrapper.py Trivial-Fix: Fix typos 2016-06-13 06:41:08 +00:00
test_mapper.py [Py34] Enable api.openstack.test_mapper unit test 2015-10-05 18:59:28 +03:00
test_requestlog.py Stop using NoAuthMiddleware in tests 2019-10-14 11:43:52 -05:00
test_wsgi.py Bump to hacking 1.1.0 2019-04-12 16:23:49 +01:00