dmacvicar / terraform-provider-libvirt

Terraform provider to provision infrastructure with Linux's KVM using libvirt
Apache License 2.0
1.6k stars 458 forks source link

Secure Boot Support #967

Open git-noise opened 2 years ago

git-noise commented 2 years ago

System Information

Linux distribution

Ubuntu 22.04

Terraform version

Terraform v1.2.6
on linux_amd64

Provider and libvirt versions

0.6.14

Checklist

Description of Issue/Question

Setup

Not tf specific

Steps to Reproduce Issue

Not a bug


Additional information:

Do you have SELinux or Apparmor/Firewall enabled? Some special configuration? Have you tried to reproduce the issue without them enabled?

Not relevant here

Issue description

In its current state, it does not seem that the provider supports Secure Boot without some xslt modification.

  1. Secure boot may be relevant these days in virtualization, and as UEFI boot-loader are already supported via OVMF by the provider, it may make sense to extend the provider to allow for secure boot support?
  2. As we're tweaking the CPU, xslt may not be the best way to do the modification as the provider may not correctly detect the changes and try to re-apply a new VM, hence disrupting the existing one.
  3. As OVMF is already supported, enabling secure boot is essentially a matter of:
    • Enable SMM CPU feature
    • Enable Secure boot flag

Regarding code-base actual changes it means at least:

One caveat is that "secure" Secure Boot with SMM and OVMF needs Q35 - with all the implication of using Q35 over i440FX. On top of my head, missing IDE support would certainly impact cloud-init ISO workflows.

git-noise commented 2 years ago

@dmacvicar I have a working branch ready with aforementioned modifications - let me know if you're interested in merging such a feature.

scabala commented 2 months ago

@git-noise did you manage to create a working version? It might get merged eventually if you are interested in it

git-noise commented 2 months ago

@scabala it has been quite a while, but I had a working version back then. I'll try and see if I can dig something.

dmacvicar commented 2 months ago

I'd prefer that we try to map as close to libvirt definition as possible, instead of abstracting it away. Even if it requires a bit more verbosity in the definition. It becomes painful to map state otherwise.

git-noise commented 1 month ago

I isolated the changes I used back in the days, but a few things seems to have changed with some newer distributions, so I am still untangling these. We can maybe then adopt a tf mapping that is close enough to the libvirt one.