Skip to content

Conversation

@nalind
Copy link
Member

@nalind nalind commented Nov 4, 2025

What type of PR is this?

/kind other

What this PR does / why we need it:

Use the Go toolchain to cross-compile the "This image is designed to be run as a confidential workload using libkrun." entrypoint that we add to confidential workload images. It's bigger than it was before, but easier to port and can be built from source every time.

How to verify it

Check that we can still build on non-amd64 architectures.

Which issue(s) this PR fixes:

Special notes for your reviewer:

Sets up #6469, if we need to stop checking in a pre-built binary.

Does this PR introduce a user-facing change?

None

@nalind nalind added the No New Tests Allow PR to proceed without adding regression tests label Nov 4, 2025
@packit-as-a-service
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@nalind nalind force-pushed the mkcw-entrypoint branch 2 times, most recently from 2395f99 to 2c09bf9 Compare November 4, 2025 23:02
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

That is a great idea to reuse go, I wonder do we have any test for this binary at all? I don;t see the messages matched anywhere in our tests? I mean we could only run it on amd64 but still I guess it would be nice to know the binary is functional?

Comment on lines +71 to +76
internal/mkcw/embed/entrypoint_arm64.gz: internal/mkcw/embed/entrypoint_arm64
gzip -k9nf $^
internal/mkcw/embed/entrypoint_ppc64le.gz: internal/mkcw/embed/entrypoint_ppc64le
gzip -k9nf $^
internal/mkcw/embed/entrypoint_s390x.gz: internal/mkcw/embed/entrypoint_s390x
gzip -k9nf $^
Copy link
Member

Choose a reason for hiding this comment

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

What do we need the other arches for if we only ever embed the amd64 one? Seems like unnecessary churn having to maintain a assembly version for each arch that we don't ever end up using.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't build them, but the confidential workload folks have been making noises about supporting other architectures for a while now.

Copy link
Collaborator

@flouthoc flouthoc left a comment

Choose a reason for hiding this comment

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

LGTM

@nalind
Copy link
Member Author

nalind commented Nov 5, 2025

Had to add the prebuilt binary back to avoid breaking people who vendor us as a library.

@Luap99
Copy link
Member

Luap99 commented Nov 5, 2025

Had to add the prebuilt binary back to avoid breaking people who vendor us as a library.

How is the code reachable? Only via buildah mkcw or also directly via the normal podman/buildah build commands?
Because right now the code/package gets imported in podman and as such podman embeds the same binary so I think we would need to apply the same fix in podman to rebuild the binary in the vendor dir as part of the specfile I think?

IF it is not needed for build it might make sense to try to split the packages so it does not get leaked into podman then?

@nalind
Copy link
Member Author

nalind commented Nov 5, 2025

Had to add the prebuilt binary back to avoid breaking people who vendor us as a library.

How is the code reachable? Only via buildah mkcw or also directly via the normal podman/buildah build commands? Because right now the code/package gets imported in podman and as such podman embeds the same binary so I think we would need to apply the same fix in podman to rebuild the binary in the vendor dir as part of the specfile I think?

build has a --cw flag which changes how we commit the final image, along similar lines.

@Luap99
Copy link
Member

Luap99 commented Nov 5, 2025

build has a --cw flag which changes how we commit the final image, along similar lines.

Ack, so then I guess we just need to figure out a way how to rebuild this binary as part of the podman rpm then. Since buildah has top level code the Makefile is actually part of vendor/. So I suppose the simple way would be to cd into vendor and just rerun the target like we do here.

cc @lsm5

Copy link
Member

@lsm5 lsm5 left a comment

Choose a reason for hiding this comment

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

spec change looks good.

LGTM. Thanks a lot @nalind

@lsm5
Copy link
Member

lsm5 commented Nov 5, 2025

Ack, so then I guess we just need to figure out a way how to rebuild this binary as part of the podman rpm then. Since buildah has top level code the Makefile is actually part of vendor/. So I suppose the simple way would be to cd into vendor and just rerun the target like we do here.

ack. Once this is vendored we can update the podman spec.

@nalind
Copy link
Member Author

nalind commented Nov 5, 2025

Native strip was removing the architecture from the ELF headers, switched to linking with -s.

@nalind nalind force-pushed the mkcw-entrypoint branch 3 times, most recently from 7659349 to 2841c21 Compare November 5, 2025 22:48
@@ -0,0 +1,12 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

nit: scripts tend to use #!/usr/bin/env bash here

b288b7a

Copy link
Member Author

Choose a reason for hiding this comment

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

We seem to be inconsistent about it, but sure, changing it.

arm64) QEMUARCH=aarch64;;
ppc64le|s390x) QEMUARCH=$GOARCH;;
esac
test "$(qemu-$QEMUARCH ./entrypoint_$GOARCH)" = "$msg"
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to add a || echo "./entrypoint_$GOARCH is not working" show easy which arch failed?
Right now the script is not set -e either so this could fail silently and the script exit code could still be 0 if the latest s390x arch works.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, the tool outputs the error message and exits with an error code, so it's a little trickier. Changed it.

Use the Go toolchain to cross-compile the "This image is designed to be
run as a confidential workload using libkrun." entrypoint that we add to
confidential workload images.  It's bigger than it was before, but
easier to port and can be built from source every time when desired.

Signed-off-by: Nalin Dahyabhai <[email protected]>
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 6, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, lsm5, Luap99, nalind

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Luap99,flouthoc,lsm5,nalind]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 70220fa into containers:main Nov 6, 2025
37 of 41 checks passed
@nalind nalind deleted the mkcw-entrypoint branch November 6, 2025 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved kind/other lgtm No New Tests Allow PR to proceed without adding regression tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants