Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vTPM basic tests #160

Merged
merged 4 commits into from
Sep 14, 2023
Merged

vTPM basic tests #160

merged 4 commits into from
Sep 14, 2023

Conversation

tescande
Copy link
Contributor

This PR adds pytest script to create a vtpm device attached to a VM, execute some basic TPM tests, and destroy the vtpm device.

@tescande tescande self-assigned this Aug 23, 2023
@tescande tescande force-pushed the vtpm-basic-tests branch 3 times, most recently from 759a2d5 to fc52d28 Compare August 23, 2023 13:39
@tescande
Copy link
Contributor Author

Not added to jobs.py yet on purpose

@tescande tescande marked this pull request as draft August 23, 2023 13:45
tests/misc/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/misc/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/misc/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/misc/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/misc/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/misc/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/misc/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/misc/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
@tescande tescande force-pushed the vtpm-basic-tests branch 2 times, most recently from 5566609 to 1315fd0 Compare August 23, 2023 14:33
@tescande tescande marked this pull request as ready for review September 5, 2023 16:36
@tescande tescande requested a review from stormi September 5, 2023 16:36
@tescande tescande force-pushed the vtpm-basic-tests branch 3 times, most recently from 7bfc527 to 11805a7 Compare September 5, 2023 17:00
lib/vm.py Outdated Show resolved Hide resolved
tests/vtpm/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/vtpm/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/vtpm/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/vtpm/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/vtpm/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
conftest.py Outdated Show resolved Hide resolved
lib/vm.py Outdated Show resolved Hide resolved
lib/vm.py Outdated Show resolved Hide resolved
lib/vm.py Outdated Show resolved Hide resolved
tests/vtpm/conftest.py Outdated Show resolved Hide resolved
tests/vtpm/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/vtpm/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/vtpm/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/vtpm/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/vtpm/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
@stormi
Copy link
Member

stormi commented Sep 6, 2023

By the way, jobs.py (discussed earlier) and vm-data.py-dist (discussed earlier too, but I forgot to mention the -dist file is the source for our vm-data.py files) still have to be updated with a new vtpm job.

@tescande
Copy link
Contributor Author

tescande commented Sep 7, 2023

By the way, jobs.py (discussed earlier) and vm-data.py-dist (discussed earlier too, but I forgot to mention the -dist file is the source for our vm-data.py files) still have to be updated with a new vtpm job.

I'll add jobs.py for the sake of check jobs but the UEFI Debian 12 image has to added to the single VM list in vm_data.py.

@stormi stormi closed this Sep 7, 2023
@stormi stormi reopened this Sep 7, 2023
@stormi
Copy link
Member

stormi commented Sep 7, 2023

I'll add jobs.py for the sake of check jobs but the UEFI Debian 12 image has to added to the single VM list in vm_data.py.

Not for the sake of check jobs. For your new test to be usable in our CI at all, because all test suites are started by ./jobs.py. And don't forget vm_data-dist.py which is the reference file for building your own vm-data.py.

Then yes, we'll have to update our internal CI vm-data.py, of course, or the job will fail.

Some xe commands, like vtpm-destroy, need to be passed a --force
parameter. Since it doesn't take any value, it needs to be handled like
the --minimal argument.

This patch adds support for a force=True|False parameter to host.xe(),
with force=False being the default.

Signed-off-by: Thierry Escande <[email protected]>
@tescande tescande force-pushed the vtpm-basic-tests branch 2 times, most recently from 59810f3 to c50e4c4 Compare September 7, 2023 15:28
jobs.py Outdated Show resolved Hide resolved
jobs.py Show resolved Hide resolved
lib/vm.py Outdated Show resolved Hide resolved
tests/vtpm/conftest.py Outdated Show resolved Hide resolved
tests/vtpm/conftest.py Outdated Show resolved Hide resolved
tests/vtpm/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/vtpm/test_vtpm_basic_operations.py Outdated Show resolved Hide resolved
tests/vtpm/conftest.py Outdated Show resolved Hide resolved
@stormi
Copy link
Member

stormi commented Sep 12, 2023

And don't forget vm_data-dist.py which is the reference file for building your own vm-data.py.

This.

Actual name is vm-data.py-dist.

@tescande tescande changed the title Vtpm basic tests vTPM basic tests Sep 13, 2023
@tescande tescande force-pushed the vtpm-basic-tests branch 2 times, most recently from 30e3ff4 to ccc2dc2 Compare September 13, 2023 09:42
tests/vtpm/conftest.py Outdated Show resolved Hide resolved
tests/vtpm/conftest.py Outdated Show resolved Hide resolved
If vm.shutdown() is called with force_if_fails set to True and the first
call to 'xe vm-shutdown' fails, then a forced shutdown will be tried.
The default value for the parameter force_is_false is False. Also, force
and force_if_fails parameters are mutually exclusive and cannot be both
True.

Signed-off-by: Thierry Escande <[email protected]>
This adds get_vtpm(), create_vtpm(), and destroy_vtpm() methods to the
VM class.

vm.get_vtpm() returns the vtpm uuid associated to the vm if it exists,
None otherwise.

vm.create_vtpm() creates a vtpm and associates it to the vm. It returns
the newly created vtpm uuid, or fails if a vtpm is already associated to
the vm.

vm.destroy_vm() destroys the existing vtpm associated to the vm if one
exists. It doesn't fail if no vtpm is associated to the vm.

Signed-off-by: Thierry Escande <[email protected]>
This change adds tests for vTPM functionalities requiring XCP-ng 8.3 and
a Unix UEFI VM.

The first test creates and destroys a vtpm device. A second test does
basic TPM tests (like message signing) using tpm2-tools.

Nested fixtures are defined for the second test, starting a snapshotted
UEFI VM with a vTPM device attached.

Signed-off-by: Thierry Escande <[email protected]>
Copy link
Member

@stormi stormi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're good!

@stormi stormi merged commit 4e21ee0 into master Sep 14, 2023
4 checks passed
@stormi stormi deleted the vtpm-basic-tests branch September 14, 2023 16:13
@stormi
Copy link
Member

stormi commented Sep 14, 2023

I transmitted the informations to Gaël for him to add this new job to our CI.

@tescande
Copy link
Contributor Author

\o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants