-
Notifications
You must be signed in to change notification settings - Fork 159
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 : add state management #4223
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you delete an app instance, do you first purge and then delete the swtpm instance?
Down the road might need garbage collection as well to handle the case when
- app instance is deployed - running
- device is powered off
- app instance is deleted in controller
- device is powered on
In that sequence the EVE agents to not see any delete handler being called; merely the absense of a create handler. We have specific logic in e.g., volumemgr to look for which volumes and content-trees (latter managed by containerd) no longer have any references from the config and gabage collect those to handle such a sequence.
Other things which store state in /persist need something similar.
Kicking off tests.
That's a good point. As far as I understand, the current implementation will also not handle the case when we start swTPM for the same domain twice (for example, after rebooting the node), as it will try to create some files again, but they already exist. Or maybe I'm wrong? |
No, if a (id,pid) pair already exist in the list of instances, vTPM just returns with no action, but I'll add a comment to make it more clear, in any other case, it just checks that the required directory exists and creates them if not (no overwriting). eve/pkg/vtpm/swtpm-vtpm/src/main.go Lines 283 to 285 in 7e06339
|
But the |
Sorry I thought you mean rebooting the VM, in that case it is still safe, vTPM calls In no case vTPM overwrites the data, it just creates if no dir exist with ID name, and deletes the ID dir when VM is being deleted (not turned off, rebooted or crashed, only deleted). |
commented in the code for brevity. |
Do we have any test cases for this? |
Thanks. @shjala ! And what about the case that @eriknordmark has described? Removal of the app that was deleted while the device was not booted. Hence, we do not have a call to |
We have unit test and eden test, the eden test tests both Aziot and vTPM, but still not merged because #4204 is not part of any release yet : I have ran both tests manually and it pass, and I'm cleaning the TPM required unit tests a bit, in another PR I'll add the vTPM unit test to that workflow. |
@OhmSpectator I need to dig into it and figure out how to do it, I'll do it in another PR if thats OK. |
Ok, that makes sense. |
@eriknordmark I'll expand the eden test to test for the case you described too. |
it was already part DomainStatus.VMConfig, I changed it based on your comment. I'm confused. |
my bad, names are too similar. |
In general, I like the new approach! Clean and clear! |
yeah, sorry for the confusion... |
Move vTPM related code from hypervisor.go to kvm.go since for now it is only KVM specific. Add uniform vTPM state management for all hypervisors. In addition improve vTPM state management by sending terminate and purge requests when it is appropriate. Signed-off-by: Shahriyar Jalayeri <shahriyar@zededa.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, looks good to me. Nevertheless, let's @eriknordmark also take a look.
Also, let's run the tests.
Waiting for https://api.github.com/repos/lf-edge/eve/actions/workflows/build.yml/runs?head_sha=1bc865f22e6bf6b4f46ca253863ce691787d17a4&status=success to return a non-empty list and then rerun the tests... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rerun the tests
@shjala, by the way, for the case when we use the I would like to clarify it before merging. |
AFAIK in HW TPM_Init flag sets some internal TPM flags to make it operational, here it is sent by Qemu through the SWTPM control socket. I like to keep it this way to be as close to the HW implementation as possible. |
@OhmSpectator if you like to know more : Seabios sends the |
Got it, thanks! |
All green! @shjala, don't you mind if we merge it? =) |
go for it thanks! |
This PR add state management to vTPM, allowing the domain manager/kvm to :
(Research has shown Friday is best day to write buggy code, so I keep it in draft state to test some more with Eden and make sure everything works as expected)