[next] Support virtualized TPM attachments to qemu VMS, plus refactor.#346
Conversation
c5baa6e to
18ea701
Compare
|
meta-nilrt 977 has been merged, unblocking this PR. Patch V2
|
18ea701 to
1a7b4a1
Compare
Patch v2
|
QEMU throws an error when executing the start script like ... ``` qemu-system-x86_64: -drive if=pflash,format=raw,readonly,file=./OVMF/OVMF_CODE.fd: warning: short-form boolean option 'readonly' deprecated Please use readonly=on instead ``` Use the new option syntax to satisfy the warning. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
Using the swtpm package, linux users can emulate a TPM device - which is useful when testing Secure Boot and NI Device Encryption workflows locally. Add a `-t` option to the QEMU start script that creates and attaches a software TPM to the VM. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
The build.vms.sh pipeline script and associated vm-resources are somewhat difficult to comprehend and also use a statically built OVMF UEFI BIOS. In order to support TPM-based secure-boot/measured-boot testing, we should use the OVMF output from OE. While we're here, refactor the build.vms tooling to use a Makefile in a directory called `qemu`, which is hopefully a little easier to maintain. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
Docker issues two warnings with the current Dockerfile. 1. Warns that the PYREX_IMAGE arg can have a blank value, resulting in an invalid Dockerfile. This is mostly fine, but change to let it use `pyrex-oe` as a default, so that docker will stop complaining. 2. Warns that 'FROM' and 'as' on line 2 use different casing. So make them both uppercase. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
1a7b4a1 to
9f02ddf
Compare
Patch v3
|
chaitu236
left a comment
There was a problem hiding this comment.
Everthing else looks fine except removal of build.vms.sh
|
BLOCKED. Block this PR merge until Jeff and I resolve his PR here. |
| s) | ||
| snapshot=true | ||
| ;; | ||
| t) |
There was a problem hiding this comment.
Should we have an explicit check/error if swtpm_setup can't run? Something like this:
t)
if ! command -v swtpm_setup &>/dev/null; then
echo "ERROR: -t requires swtpm-tools, but it is not installed or not in PATH" >&2
exit 1
fi
tpm=true
;;
There was a problem hiding this comment.
I usually try to avoid doing explicit checks for binaries, unless there are bad consequences for just allowing the later commands in the script to fail. In this case, all that would happen is that the start script would create the ./tpm directory in the VM location and then fail with a "command not found" error. I think that's OK.
| ni_provisioning.answers.iso | ||
| $(primary_disk_path) : $(vmdeps) | ||
| rm -f "$@" | ||
| qemu-img create -f qcow2 "$@" "$(DISK_SIZE_MB)""M" |
There was a problem hiding this comment.
Should qemu-img be wrapped with $(PYREX_RUN) like is done for qemu-system-x86_64? Looks like it used to be wrapped in the previous build.vms.sh.
There was a problem hiding this comment.
You're right; will fix.
jpautler
left a comment
There was a problem hiding this comment.
LGTM other than the couple open comments and the separate PR with Makefile changes.
Bitbake cannot handle concurrent invocations against the same build directory. Without .NOTPARALLEL, running 'make -j' or running make from our pipelines could trigger multiple simultaneous bitbake calls, causing lock errors. Signed-off-by: Jeffrey Pautler <jeffrey.pautler@ni.com>
The '&:' grouped target syntax is only valid for explicit targets in GNU make, not pattern rules with '%'. Using a pattern rule caused make to treat ovmf.code.fd and ovmf.vars.fd as independent targets, resulting in two 'bitbake ovmf' invocations. Replace the pattern rule with explicit grouped targets. Signed-off-by: Jeffrey Pautler <jeffrey.pautler@ni.com>
Building nilrt-recovery-media wipes the shared deploy directory as part of its do_image clean step, deleting ovmf.code.fd and ovmf.vars.fd. Bitbake's existing stamps still show ovmf as complete, so a plain 'bitbake ovmf' skips do_deploy and leaves the files absent. Use '-C deploy' to invalidate and rerun do_deploy regardless of stamp state. Signed-off-by: Jeffrey Pautler <jeffrey.pautler@ni.com>
The previous KVMOPTS used '$(shell ...)' which runs on the host at make parse time. When invoked via the pipeline, qemu runs inside a pyrex container that does not have /dev/kvm mapped, so passing -enable-kvm unconditionally caused qemu to fail. Replace KVMOPTS with an inline shell test run through PYREX_RUN so the check executes in the same container context as qemu itself. Signed-off-by: Jeffrey Pautler <jeffrey.pautler@ni.com>
Place all intermediate and final build artifacts under bbdir rather than in the Makefile's working directory. Introduce builddir_tmp for ephemeral files and builddir_zip_contents for the zip staging area. Signed-off-by: Jeffrey Pautler <jeffrey.pautler@ni.com>
The nilrt OE build system uses tmp-glibc as its work directory, not tmp. Signed-off-by: Jeffrey Pautler <jeffrey.pautler@ni.com>
Use the PYREX_RUN wrapper script to ensure that qemu-img commands are run within the pyrex container, so that we have better control over the toolchain available. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
Patch v4
|
Changes
-t). When asserted, the script will create, initialize, and attach a virtualized TPM2.0 device to the VM using theswtpmdistro package on the host machine.build.vms.shbash script, use a Makefile - where the logic is easeier to parse.ovmfrecipe in OE-core to build the UEFI firmware, instead of using a static copy from somewhere.AB#3752806
Testing
Process
Suggested Reviewers: