nova/nova/tests/unit/image
Adam Spiers b4905467db Add extra spec parameter and image property for memory encryption
Add a new "hw:mem_encryption" extra spec parameter, and a new
"hw_mem_encryption" image property, which indicate that any guest
booted with that extra spec parameter or image property respectively
needs to be booted with its memory hardware-encrypted.

This is achieved by converting the requirement stated in the extra
spec parameter and/or image property into an additional extra spec
parameter which requests resources for one slot of the inventory of
the new MEM_ENCRYPTION_CONTEXT resource class (introduced in
os-resource-classes 0.4.0).  The inventory will be provided by the
follow-up commit I659cb77f12a38a4d2fb118530ebb9de88d2ed30d.

Since future commits adding support for SEV to guest XML config will
also need to know at launch-time whether memory encryption has been
requested, add a reusable mem_encryption_requested() function to the
nova.virt.hardware library for detecting which of the extra spec /
image property (if either) have requested encrypted memory.

If both the extra spec parameter and the image property are explicitly
specified and they contradict each other, or if either request memory
encryption but the image does not have hw_firmware_type set to UEFI,
then log an error and raise a new generic FlavorImageConflict
exception.  This exception can also be useful in the future for
handling other similar conflicts.  In this particular use case,
FlavorImageConflict is raised by mem_encryption_requested(), and then
if caught during API call validation, it's re-raised as
HTTPBadRequest.

In order to test this code, we need to construct various ImageMeta
objects containing fake data and a ImageMetaProps instance for each.
This is a slightly fiddly task which future patches in the SEV series
will also need to perform, so add a helper to nova.tests.unit.image.fake
for this.

blueprint: amd-sev-libvirt-support
Change-Id: I8c63b5cc5ad97ce831adb2eb96a995ebc798ecb7
2019-09-01 15:17:31 +01:00
..
__init__.py move all tests to nova/tests/unit 2014-11-12 15:31:08 -05:00
abs.tar.gz move all tests to nova/tests/unit 2014-11-12 15:31:08 -05:00
fake.py Add extra spec parameter and image property for memory encryption 2019-09-01 15:17:31 +01:00
rel.tar.gz move all tests to nova/tests/unit 2014-11-12 15:31:08 -05:00
test_fake.py Transform compute_task notifications 2018-11-21 16:23:28 +09:00
test_glance.py Bump to hacking 1.1.0 2019-04-12 16:23:49 +01:00