Skip to content

Comments

qemu_template.sh: Add support for attaching a software TPM#1827

Merged
pothos merged 6 commits intomainfrom
kai/qemu-swtpm
Apr 4, 2024
Merged

qemu_template.sh: Add support for attaching a software TPM#1827
pothos merged 6 commits intomainfrom
kai/qemu-swtpm

Conversation

@pothos
Copy link
Member

@pothos pothos commented Apr 3, 2024

  • qemu_template.sh: Add support for attaching a software TPM

    For testing TPM2-backed rootfs encryption it is handy to have a software
    TPM option for the qemu script.
    Add a flag for a software TPM with swtpm like kola also does. The user
    has to specify a folder for the secret state and this won't be removed
    because the same store should be able to be passed when booting the VM
    again after shutdown.

  • vm_image_util.sh: Bump default VM memory to 2 GB

    While Flatcar itself runs fine with 1 GB, many workloads do not and
    having to debug this is time consuming when one forgets to bump the VM
    memory, e.g., in the Qemu script.
    Default to 2 GB as known-good setting for things like Kubernetes or
    setting up LUKS devices.

  • qemu_template.sh: Allow parameters for VM image and memory

    When testing multiple images one always has to copy them to the
    expected file name, and when trying to run two VMs this means one needs
    to either use separate directories or modify the qemu script. One also
    needs to modify the qemu script to bump the memory for K8s or for LUKS.

    Support parameters for the VM image name and the VM memory.

(Note that the kola tests for qemu and vmware all use 2 GB or slightly more. Thus it makes sense to default to this as well in the release artifacts we provide to the users.)

How to use

./flatcar_production_qemu.sh -T myswtpmdir

Testing done

The above and verified that the swtpm process gets cleaned up even when qemu doesn't start, e.g., ./flatcar_production_qemu.sh -T swtpm-dir -- -unknown-arg

Downloaded rendered template and checked that memory and image location settings work.

  • Changelog entries added in the respective changelog/ directory (user-facing change, bug fix, security fix, update)
  • Inspected CI output for image differences: /boot and /usr size, packages, list files for any missing binaries, kernel modules, config files, kernel modules, etc.

@pothos pothos requested a review from a team April 3, 2024 12:11
@github-actions
Copy link

github-actions bot commented Apr 3, 2024

Build action triggered: https://github.com/flatcar/scripts/actions/runs/8549074654

pothos added 4 commits April 4, 2024 12:55
When testing multiple images one always has to copy them to the
expected file name, and when trying to run two VMs this means one needs
to either use separate directories or modify the qemu script. One also
needs to modify the qemu script to bump the memory for K8s or for LUKS.

Support parameters for the VM image name and the VM memory.
While Flatcar itself runs fine with 1 GB, many workloads do not and
having to debug this is time consuming when one forgets to bump the VM
memory, e.g., in the Qemu script.
Default to 2 GB as known-good setting for things like Kubernetes or
setting up LUKS devices.
For testing TPM2-backed rootfs encryption it is handy to have a software
TPM option for the qemu script.
Add a flag for a software TPM with swtpm like kola also does. The user
has to specify a folder for the secret state and this won't be removed
because the same store should be able to be passed when booting the VM
again after shutdown.
The qemu UEFI and regular qemu script only differ by having a default
value for the firmware. If one tries to switch between different
firmwares one normally would modify the script.
Make it easier to switch boot modes and use custom firmwares by
supporting a flag to set the pflash contents.
@pothos
Copy link
Member Author

pothos commented Apr 4, 2024

Pushed one more change to also allow setting the pflash contents through a flag to switch between firmwares more easily, e.g., BIOS, UEFI, and UEFI with Secure Boot.

Edit: And for the PXE boot script two parameters to set the kernel and initrd files to be used.

pothos added 2 commits April 4, 2024 16:53
For the swtpm version in Ubuntu some init command is required first.
With the PXE script it is easy to boot different versions from one
folder without any copies because the kernel and PXE initrd are always
"fresh".
Instead of only supporting hardcoded file names, support parameters for
the kernel and initrd file to be used.
@pothos pothos requested a review from a team April 4, 2024 07:55
@pothos pothos merged commit 395c884 into main Apr 4, 2024
@pothos pothos deleted the kai/qemu-swtpm branch April 4, 2024 08:21
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.

2 participants