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

tests: rebuild OVMF and use generated keys #14960

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

valentindavid
Copy link
Contributor

@valentindavid valentindavid commented Jan 22, 2025

Depends on #14959

The generated OVMF_VARS also contains microsoft "other" db cert. And also the certs for the pc-kernel edge. As well as the now deprecated snakeoil cert.

@valentindavid valentindavid added the Run nested The PR also runs tests inluded in nested suite label Jan 22, 2025
@valentindavid valentindavid force-pushed the valentindavid/build-ovmf branch from ca6ff95 to a01e5da Compare January 22, 2025 10:52
Copy link

github-actions bot commented Jan 22, 2025

Wed Feb 5 09:06:50 UTC 2025
The following results are from: https://github.com/canonical/snapd/actions/runs/13137537509

Failures:

Preparing:

  • google-nested:ubuntu-24.04-64:tests/nested/manual/remodel-min-size

Executing:

  • google:ubuntu-25.04-64:tests/main/cgroup-devices-v2
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-serial-port
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups:kmsg
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-helper
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-self-manage
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-required-or-optional
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-strict-enforced
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups:uinput

Restoring:

  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-strict-enforced

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (master@b7a1756). Learn more about missing BASE report.
Report is 64 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master   #14960   +/-   ##
=========================================
  Coverage          ?   78.22%           
=========================================
  Files             ?     1164           
  Lines             ?   154351           
  Branches          ?        0           
=========================================
  Hits              ?   120739           
  Misses            ?    26171           
  Partials          ?     7441           
Flag Coverage Δ
unittests 78.22% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- nasm
- acpica-tools
plugin: nil
source: https://github.com/tianocore/edk2.git
Copy link
Contributor

Choose a reason for hiding this comment

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

could we use ovmf and efi-shell from 24.04 instead?

@valentindavid valentindavid force-pushed the valentindavid/build-ovmf branch from a01e5da to 8cce59c Compare January 22, 2025 11:26
Copy link
Contributor

@bboozzoo bboozzoo left a comment

Choose a reason for hiding this comment

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

The remaining open question is whether we should have a tests which uses ovmf packages from the repo to run the VM like the docs page at https://ubuntu.com/core/docs/testing-with-qemu state. Or perhaps that's a job to be run in some other repository (core-base?)

@@ -0,0 +1,140 @@
name: ovmf
Copy link
Contributor

Choose a reason for hiding this comment

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

we can name it test-snapd-ovmf, update description to mention that that it's ovmf binaries with some testing keys enrolled used for snapd CI and push it to the store

Copy link
Contributor

Choose a reason for hiding this comment

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

I've opened a name request for test-snapd-ovmf. Can move the snap files to tests/lib/snaps/store/test-snapd-ovmf ?

Comment on lines 86 to 87
install -Dm644 -t "${CRAFT_PART_INSTALL}/secboot" \
LockDown.efi {PK,KEK,DB}.{key,crt}
Copy link
Contributor

Choose a reason for hiding this comment

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

this will generate new keys each time during the build which isn't obvious. Probably not a problem but users need to be aware of it. Or we can drop pre-generated keys into the snap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The point here is people not to test explicitly a key. They have to test if a key matches specifically DB or KEK. And not just a constant hash in some test.

-drive "if=pflash,file=${OVMF}_VARS.fd,format=raw" \
-drive "if=virtio,file=${CRAFT_STAGE}/lockdown.img,format=raw" >qemu.out 2>qemu.err </dev/null
install -Dm644 "${OVMF}_VARS.fd" "${CRAFT_PART_INSTALL}/fw/${OVMF}_VARS.secboot.fd"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
install -Dm644 "${OVMF}_VARS.fd" "${CRAFT_PART_INSTALL}/fw/${OVMF}_VARS.secboot.fd"
install -Dm644 "${OVMF}_VARS.fd" "${CRAFT_PART_INSTALL}/fw/${OVMF}_VARS.secboot-testkeys.fd"

return
fi
if ! [ -f "${NESTED_ASSETS_DIR}/ovmf.snap" ]; then
(cd "${TESTSLIB}/snaps/ovmf"; run_snapcraft --use-lxd --verbosity quiet --output="${NESTED_ASSETS_DIR}/ovmf.snap")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd rather download the snap from store rather than build it, or even fail explicitly and expect run-spread to do the download.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. I will keep it in the draft for now. When the tests seem to work, I will add some CI step that uploads it.

@valentindavid
Copy link
Contributor Author

The remaining open question is whether we should have a tests which uses ovmf packages from the repo to run the VM like the docs page at https://ubuntu.com/core/docs/testing-with-qemu state.

We have tests/main/mkimage-uc22

@@ -0,0 +1,140 @@
name: ovmf
Copy link
Contributor

Choose a reason for hiding this comment

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

I've opened a name request for test-snapd-ovmf. Can move the snap files to tests/lib/snaps/store/test-snapd-ovmf ?

Comment on lines 5 to 6
summary: EDK2
description: EDK2
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
summary: EDK2
description: EDK2
summary: Pre-built OVMF blobs with test keys for snapd CI
description: |
Pre-built OVMF blobs with enrolled test keys for use in snapd CI loop.
The following known keys are enrolled:
- snakeoil - ## ref?
- kernel PPA
<whichever we key we add>

@valentindavid valentindavid force-pushed the valentindavid/build-ovmf branch 6 times, most recently from 19ba700 to 81ccf1d Compare January 24, 2025 10:01
Copy link
Contributor

Choose a reason for hiding this comment

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

can you rename the directory to tests/lib/snaps/store/test-snapd-ovmf?

@valentindavid valentindavid force-pushed the valentindavid/build-ovmf branch 13 times, most recently from 5bfbbd3 to 028fefe Compare January 26, 2025 21:43
@valentindavid valentindavid force-pushed the valentindavid/build-ovmf branch 10 times, most recently from d509075 to 74459a7 Compare January 31, 2025 08:49
@valentindavid valentindavid force-pushed the valentindavid/build-ovmf branch from 74459a7 to d547746 Compare February 4, 2025 10:27
@valentindavid valentindavid marked this pull request as ready for review February 4, 2025 10:28
fi
PARAM_BIOS="-drive file=${OVMF_CODE},if=pflash,format=raw,readonly=on -drive file=${OVMF_VARS},if=pflash,format=raw"
Copy link
Contributor

Choose a reason for hiding this comment

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

Before we got a new copy of the vars blob for each run, and optionally, only in the fde branch, the state file could be kept around. however, with the changes right now we'll reuse the vars blob file each time. IMO it'd be better to keep the old behavior of starting with a clean copy.

Suggested change
PARAM_BIOS="-drive file=${OVMF_CODE},if=pflash,format=raw,readonly=on -drive file=${OVMF_VARS},if=pflash,format=raw"
OVMF_VARS_TMP="${OVMF_VARS}.tmp"
# make a copy of the original VARS blob, so that we start with a clean slate
cp -fv "$OVMF_VARS" "$OVMF_VARS_TMP"
PARAM_BIOS="-drive file=${OVMF_CODE},if=pflash,format=raw,readonly=on -drive file=${OVMF_VARS_TMP},if=pflash,format=raw"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose I should reset unless NESTED_KEEP_FIRMWARE_STATE is defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I realize we are missing stuff from the FDE branch. For example d016c59

Copy link
Contributor

Choose a reason for hiding this comment

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

this is fine, we can either cherry pick it or simply add it in the fde branch during rebase

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cherry picked the commits needed and fixed the commit.

…are-state

When restarting a nested VM, we reset the EFI variables and the TPM.
It was possible to keep the state of the TPM, but it makes little
sense to keep the TPM but not the EFI variables. With the new secboot,
both resetting EFI and resetting the TPM will potentially cause
recovery key to be needed.

This fixes the case where an installer image would create a sbatlevel
revocation, and get a different one after reset and boot with the
gadget snap.
Some tests like
`tests/nested/manual/core20-install-mode-shutdown-via-hook` source
this script with `-u` set. So `NESTED_KEEP_FIRMWARE_STATE` which is
potentially unbound has to be used as such.
@valentindavid valentindavid force-pushed the valentindavid/build-ovmf branch from d547746 to 0864abd Compare February 4, 2025 14:04
@valentindavid valentindavid force-pushed the valentindavid/build-ovmf branch from 0864abd to 753794f Compare February 4, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Run nested The PR also runs tests inluded in nested suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants