Skip to content

refactor: remove dead code, fix silent socket option no-ops, fix tempdir leak - #37

Merged
danbugs merged 5 commits into
mainfrom
fix/cleanup
May 15, 2026
Merged

refactor: remove dead code, fix silent socket option no-ops, fix tempdir leak#37
danbugs merged 5 commits into
mainfrom
fix/cleanup

Conversation

@danbugs

@danbugs danbugs commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Three cleanup items:

  • FsSandbox::register duplication (~190 LOC): Deleted FsSandbox::register
    which duplicated all 9 fs handlers from FsRouter::register. Only used in
    tests — updated those to use FsRouter with a single preopen, testing the
    actual production code path.
  • Silent socket option no-ops: net_setsockopt and net_getsockopt silently
    returned Ok/0 for unrecognized (level, optname) pairs. Now returns an error so
    guests can detect unsupported options.
  • pptx-gen tempdir leak: inject_script_into_rootfs used
    std::mem::forget(temp_dir) to keep the returned path valid. Now returns the
    TempDir alongside the path so the caller owns the lifetime.

Test plan

  • All host tests pass (tests now exercise production FsRouter path)
  • cargo check passes for demos/pptx-gen

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Cleanup PR that removes a duplicated FsSandbox::register method (~190 LOC) and updates its tests to exercise the production FsRouter code path, converts silent no-op behavior in net_setsockopt / net_getsockopt for unknown options into explicit errors, and fixes a TempDir leak in pptx-gen by returning the TempDir to the caller for proper lifetime ownership.

Changes:

  • Delete dead FsSandbox::register and migrate two tests to FsRouter with a /host preopen.
  • Return errors for unsupported (level, optname) pairs in net_setsockopt / net_getsockopt.
  • Return (PathBuf, TempDir) from inject_script_into_rootfs instead of mem::forget-ing the TempDir.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
host/src/lib.rs Drops FsSandbox::register duplication, updates two FS tests to use FsRouter/Preopen, and replaces silent socket-option no-ops with explicit errors.
demos/pptx-gen/src/main.rs Returns the TempDir from inject_script_into_rootfs so the caller controls its lifetime; updates caller to bind it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Linux Benchmarks

Details
Benchmark suite Current: 6c578d8 Previous: 2ad29b8 Ratio
hello_world (median) 20 ms 20 ms 1
pandas (median) 100 ms 110 ms 0.91
density (per VM) 7 MB 7 MB 1
snapshot (disk) 385 MiB 385 MiB 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Windows Benchmarks

Details
Benchmark suite Current: 6c578d8 Previous: 2ad29b8 Ratio
hello_world (median) 255 ms 316 ms 0.81
pandas (median) 815 ms 1015 ms 0.80
density (per VM) 6 MB 6 MB 1
snapshot (disk) 393 MiB 393 MiB 1

This comment was automatically generated by workflow using github-action-benchmark.

danbugs added 5 commits May 15, 2026 06:30
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
@danbugs
danbugs merged commit 0dbf112 into main May 15, 2026
76 of 79 checks passed
@danbugs
danbugs deleted the fix/cleanup branch May 15, 2026 06:42
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