Skip to content

Take guestbinary by ref instead of value #560

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ludfjig
Copy link
Contributor

@ludfjig ludfjig commented Jun 3, 2025

Depends on #559

Making Uninitialized::new take a GuestBinary by ref instead of value is more flexible, allowing reuse of the same guest binary across many different sandboxes. This PR allows passing either a ref or value, to be maximally flexible and not be a breaking change

@ludfjig ludfjig force-pushed the take_guestbinary_by_ref branch from af96a45 to 6698c2e Compare June 3, 2025 23:51
@ludfjig ludfjig added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Jun 3, 2025
dblnz
dblnz previously approved these changes Jun 4, 2025
Copy link
Contributor

@dblnz dblnz left a comment

Choose a reason for hiding this comment

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

Lgtm

@@ -132,7 +132,7 @@ impl UninitializedSandbox {
skip(guest_binary),
parent = Span::current()
)]
pub fn new(guest_binary: GuestBinary, cfg: Option<SandboxConfiguration>) -> Result<Self> {
pub fn new(guest_binary: &GuestBinary, cfg: Option<SandboxConfiguration>) -> Result<Self> {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Take Borrow<GuestBinary>, then you can take GuestBinary or &GuestBinary. That would also help reduce the number of changes in this PR, as it would be backwards compatible.

Suggested change
pub fn new(guest_binary: &GuestBinary, cfg: Option<SandboxConfiguration>) -> Result<Self> {
pub fn new(guest_binary: impl Borrow<GuestBinary>, cfg: Option<SandboxConfiguration>) -> Result<Self> {
let guest_binary = guest_binary.borrow();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! Fixed

Copy link
Contributor

@jprendes jprendes left a comment

Choose a reason for hiding this comment

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

LGTM

@ludfjig ludfjig force-pushed the take_guestbinary_by_ref branch from fc417d0 to 453819f Compare June 6, 2025 17:56
Signed-off-by: Ludvig Liljenberg <[email protected]>
@ludfjig ludfjig force-pushed the take_guestbinary_by_ref branch from 453819f to 1b28b07 Compare June 6, 2025 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants