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

Add TPM Support #260

Merged
merged 8 commits into from
May 28, 2024
Merged

Add TPM Support #260

merged 8 commits into from
May 28, 2024

Conversation

mpywell
Copy link
Contributor

@mpywell mpywell commented Apr 15, 2024

Add TPM support for Windows 11 builds.

TPM was merged into Telmate/proxmox-api-go@32c480f, v1.1.7 uses a version from ~12 months ago. Between versions changes were made upstream relating to the proxmox.ConfigQemu struct that required uplift to storage in packer-plugin-proxmox, in addition to the deprecation of the UpdateConfig and CreateVm functions.

While the tests have been updated and pass, I've also extensively tested proxmox-iso and proxmox-clone on a PVE environment and have not observed any breaking changes for packer templates that worked with v1.1.7.

Closes #73

@mpywell mpywell requested a review from a team as a code owner April 15, 2024 11:11
@svnscha
Copy link

svnscha commented May 22, 2024

Any update on this?

Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

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

Hi @mpywell,

Thanks for the PR, and sorry I haven't looked at it before today.

I left a couple questions and one suggestion regarding the function that builds the tpm config object from the config, but aside from those LGTM!

Let me know when you've had time to address those, and I'll do another round of review ASAP.

Thanks!

builder/proxmox/common/config.go Show resolved Hide resolved
builder/proxmox/common/step_start_vm.go Show resolved Hide resolved
builder/proxmox/common/step_start_vm.go Outdated Show resolved Hide resolved
Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

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

Hi @mpywell,

Thanks for the reroll and explanations! Just left a final question/suggestion regarding the reflects for building the disk slice as I'm not sure I understand why we need them, but besides that, this looks good to me.

Pre-approving so it's not a blocker later.

builder/proxmox/common/step_start_vm.go Show resolved Hide resolved
builder/proxmox/common/step_start_vm.go Show resolved Hide resolved
builder/proxmox/common/step_start_vm.go Outdated Show resolved Hide resolved
builder/proxmox/common/step_start_vm.go Outdated Show resolved Hide resolved
builder/proxmox/common/config.go Show resolved Hide resolved
@mpywell
Copy link
Contributor Author

mpywell commented May 26, 2024

Hi @lbajolet-hashicorp, hope the reflect answer helps!

If it helps with planning the 1.9 release I plan to follow this PR up with another for #257 shortly after merge. I also have some draft changes started to tackle #263 and #187 (duplicates of the same issue), and #80.

The was we set disks for a VM startup since the structure changed uses
reflection as a way to not have to do some ugly switches with named
fields.

While this works, without a good understanding of both Go's reflection
and the proxmox APIs, this is a non-trivial piece of code, that is
hardly statically validable, and error prone.

To mitigate this, we write a lengthy documentation on the first of the
reflection usages in the generateProxmoxDisks function so it explains
the whys and hows of the approach, in order to make it hopefully clearer
to future developers.
Accessing the fields of a structure through reflection is possible
through several means, namely by index, or by name.

Index-based access can be relevant, but is rather susceptible to
reordering changes later in the life of the product, and given that it
occurs at runtime only, we lose the possibility to statically detect
those changes.

Name-based access is slightly more robust, as we are avoiding issues
like new fields changing the access, and the named fields generally
change only in case of a refactor, which is rarer. Besides named
accesses are somewhat self-documentational, and refect better on what
we're trying to achieve in this code.

Therefore, we change how the reflection accesses happen for
generateProxmoxDisks, defaulting on named-based accesses instead of
index-based ones for filling in the disks.
@lbajolet-hashicorp lbajolet-hashicorp merged commit 581f739 into hashicorp:main May 28, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for "TPM State" option for system
3 participants