Skip to content

9p: add files and steps for 9p binary compilation #1051

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: release-4.18
Choose a base branch
from

Conversation

redbeam
Copy link
Contributor

@redbeam redbeam commented Apr 28, 2025

9P support for filesharing on Windows: crc-org/crc#4168

Summary by Sourcery

Add support for compiling 9p filesystem binary for Windows file sharing

New Features:

  • Implement 9pfs binary compilation for Windows support

Build:

  • Add Dockerfile for building 9pfs binary using UBI 9 image
  • Add script to compile and extract 9pfs binary on x86_64 architecture

Chores:

  • Modify createdisk scripts to support 9p filesystem binary compilation

Copy link

sourcery-ai bot commented Apr 28, 2025

Reviewer's Guide

This pull request integrates the compilation of the 9pfs binary into the Windows bundle creation process by adding a Dockerfile for the build and shell functions to orchestrate the compilation and extraction using Podman within the VM.

Sequence diagram for 9pfs compilation and extraction

sequenceDiagram
    participant BuildScript as createdisk.sh
    participant VM
    participant PodmanInVM as Podman (inside VM)

    Note over BuildScript, VM: Assumes ARCH=x86_64 and SNC_GENERATE_WINDOWS_BUNDLE!=0
    BuildScript->>VM: Calls compile_and_extract_9pfs()
    BuildScript->>VM: scp -r 9pfs ./core@VM_IP:/home/core/
    BuildScript->>VM: ssh core@VM_IP '...' (execute commands)
    activate VM
    VM->>PodmanInVM: podman build -t 9pfs-builder .
    activate PodmanInVM
    PodmanInVM-->>VM: Build Complete
    deactivate PodmanInVM
    VM->>PodmanInVM: podman create --name extract-temp 9pfs-builder
    activate PodmanInVM
    PodmanInVM-->>VM: Container Created (extract-temp)
    deactivate PodmanInVM
    VM->>PodmanInVM: podman cp extract-temp:/src/9pfs/9pfs ./9pfs
    activate PodmanInVM
    PodmanInVM-->>VM: Binary Copied
    deactivate PodmanInVM
    VM->>PodmanInVM: podman rm extract-temp
    activate PodmanInVM
    PodmanInVM-->>VM: Container Removed
    deactivate PodmanInVM
    VM-->>VM: sudo cp 9pfs /usr/local/bin
    VM-->>BuildScript: SSH command completes
    deactivate VM
Loading

File-Level Changes

Change Details Files
Added Dockerfile and shell function to compile and extract the 9pfs binary.
  • Defined a multi-stage Docker build process using UBI9 to compile 9pfs.
  • Created a new shell function (compile_and_extract_9pfs) that uses Podman to build the image, create a temporary container, copy the compiled binary out, and place it in /usr/local/bin on the VM.
createdisk-library.sh
9pfs/Dockerfile
Integrated 9pfs compilation into the main disk creation script.
  • Modified the script to conditionally call the compile_and_extract_9pfs function when generating a Windows bundle for the x86_64 architecture.
createdisk.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@openshift-ci openshift-ci bot requested review from cfergeau and gbraad April 28, 2025 09:54
Copy link

openshift-ci bot commented Apr 28, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign gbraad for approval. For more information see the Code Review Process.

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

Needs approval from an approver in each of these files:

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

@redbeam redbeam moved this to Ready for review in Project planning: crc Apr 28, 2025
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @redbeam - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider pinning the git clone in the Dockerfile to a specific commit hash or tag for reproducible builds.
  • The compile_and_extract_9pfs function copies the 9pfs directory to the VM, but the Dockerfile then clones the repository again; perhaps only the Dockerfile needs to be copied.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @redbeam - I've reviewed your changes - here's some feedback:

  • Consider building the 9pfs binary outside the target VM to simplify the process within createdisk-library.sh.
  • Pinning the 9pfs dependency to a specific commit hash might be fragile; consider using a git tag or submodule.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@redbeam redbeam force-pushed the add_9p_fuse_client branch from a1461ea to e149f5c Compare May 5, 2025 06:30
@redbeam redbeam moved this from Ready for review to Work In Progress in Project planning: crc May 5, 2025
@cfergeau
Copy link
Contributor

cfergeau commented May 5, 2025

Have you considered a similar approach to the routes-controller builds? They are done on RH build systems, snc only need to fetch the already built image and extract the binary.
Doing the build every time snc runs even when nothing has changed seems wasteful.

@redbeam
Copy link
Contributor Author

redbeam commented May 5, 2025

@cfergeau Thanks for the feedback! This was done after consulting with @praveenkumar
I'm open to try building this using RH build systems, if you can provide me with more info on this.

@redbeam redbeam changed the title 9p: added files and steps for 9p binary compilation 9p: add files and steps for 9p binary compilation May 5, 2025
@praveenkumar
Copy link
Member

@cfergeau Thanks for the feedback! This was done after consulting with @praveenkumar I'm open to try building this using RH build systems, if you can provide me with more info on this.

This approach was for POC to make sure it works as expected. Also I think it is for fuse driver instead 9p but if that need kernel headers then better to build using same image which rhel-coreos uses for that release instead based on latest ubi otherwise it will be mismatch for kernel header.

@redbeam
Copy link
Contributor Author

redbeam commented May 6, 2025

Yes, this is the FUSE client, since we chose this approach instead of the kernel module one.

@redbeam
Copy link
Contributor Author

redbeam commented May 21, 2025

/hold

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Work In Progress
Development

Successfully merging this pull request may close these issues.

5 participants