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

Reorganize code into x86_64/{elf, bzimage} and aarch64 modules #24

Merged
merged 4 commits into from
Mar 26, 2020

Conversation

alxiord
Copy link
Member

@alxiord alxiord commented Mar 10, 2020

The first 2 commits in this PR split the code that currently bloats src/loader/mod.rs into:

  1. dedicated elf and bzimage modules under loader
  2. per-arch modules:
    1. x86_64/elf
    2. x86_64/bzimage
    3. aarch64

Overall, the purpose of this reorganization is to improve readability and maintainability by keeping src/loader/mod.rs simple.

@alxiord alxiord self-assigned this Mar 10, 2020
@alxiord alxiord requested a review from andreeaflorescu March 10, 2020 13:18
@alxiord alxiord force-pushed the cleanup branch 3 times, most recently from bd6b09e to d6f52c7 Compare March 14, 2020 12:27
serban300
serban300 previously approved these changes Mar 16, 2020
Copy link

@serban300 serban300 left a comment

Choose a reason for hiding this comment

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

Looks good to me. I have only one question. Is start_info.rs needed ? It doesn't seem to be used inside the crate.

@alxiord
Copy link
Member Author

alxiord commented Mar 16, 2020

Looks good to me. I have only one question. Is start_info.rs needed ? It doesn't seem to be used inside the crate.

#11 (comment) explains why this crate should export the structs in start_info and how the VMM that imports linux-loader should use them.

@andreeaflorescu
Copy link
Member

nit: Can we organize the exports as they're organized in vmm-sys-util? You can check src/lib.rs and the mod.rs file from unix. The advantage with that approach is that when you add a new feature you don't have to grow the lib.rs file and have both the attributes for the features & for the platform at the same level.

iulianbarbu
iulianbarbu previously approved these changes Mar 18, 2020
@alxiord
Copy link
Member Author

alxiord commented Mar 18, 2020

nit: Can we organize the exports as they're organized in vmm-sys-util? You can check src/lib.rs and the mod.rs file from unix. The advantage with that approach is that when you add a new feature you don't have to grow the lib.rs file and have both the attributes for the features & for the platform at the same level.

I don't understand which structure you have in mind for lib.rs. It only exports pub mod loader, so it's pretty small. loader/mod.rs is more complicated because the error and KernelLoaderResult types there aggregates errors from all the other mods... I can't figure out a way to simplify the imports.

serban300
serban300 previously approved these changes Mar 18, 2020
@alxiord
Copy link
Member Author

alxiord commented Mar 18, 2020

@rbradford / @sameo / @sboeuf Could either of you PTAL too?

#[cfg(all(feature = "elf", any(target_arch = "x86", target_arch = "x86_64")))]
pub use x86_64::elf::Elf;
#[cfg(all(feature = "elf", any(target_arch = "x86", target_arch = "x86_64")))]
pub use x86_64::elf::Error as ElfError;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you also need a:

#[cfg(all(feature = "elf", any(target_arch = "x86", target_arch = "x86_64")))]
pub use x86_64::elf::start_info;

Copy link
Member Author

@alxiord alxiord Mar 18, 2020

Choose a reason for hiding this comment

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

I think (hope) that both this issue and @andreeaflorescu's nit #24 (comment) are solved in the latest commit. The elf and bzimage modules are used as-is, simplifying the imports in loader/mod.rs, at the expense of the user prepending elf:: and bzimage:: to structs and calls.

In preparation for more incoming code that's either elf or
bzimage specific, the respective blocks of functionality
now sit in separate modules. This makes the code easier to
navigate and improves readability.

Fixes rust-vmm#22 as well.

Signed-off-by: Alexandra Iordache <[email protected]>
@alxiord
Copy link
Member Author

alxiord commented Mar 23, 2020

@iulianbarbu @serban300 @sameo @andreeaflorescu Lost all approvals, rebased & updated, PTAL 😃

serban300
serban300 previously approved these changes Mar 23, 2020
@sameo
Copy link
Collaborator

sameo commented Mar 24, 2020

Works with Cloud Hypervisor.

sameo
sameo previously approved these changes Mar 24, 2020
src/loader/bzimage/mod.rs Outdated Show resolved Hide resolved
src/loader/elf/mod.rs Outdated Show resolved Hide resolved
src/loader/mod.rs Outdated Show resolved Hide resolved
Phase 2 of code reorganization: separate x86_64 from aarch64
functionality in modules.

Signed-off-by: Alexandra Iordache <[email protected]>
Alexandra Iordache added 2 commits March 24, 2020 16:48
Signed-off-by: Alexandra Iordache <[email protected]>
@alxiord alxiord dismissed stale reviews from sameo and serban300 via 388fd99 March 24, 2020 14:48
@alxiord
Copy link
Member Author

alxiord commented Mar 24, 2020

@iulianbarbu @serban300 @sameo @andreeaflorescu Lost all approvals, rebased & updated, PTAL

Lost again but I hope this is the last time I ask for re-approvals

@sboeuf
Copy link

sboeuf commented Mar 25, 2020

Lost again but I hope this is the last time I ask for re-approvals

Do you think we could disable this feature? I mean unless we really don't trust the people submitting code, I don't expect someone to shove some bad code on purpose between two iterations of a PR.
Moreover, if someone feel like the PR is not ready while someone else already approved it, it's only a matter of clicking the Request Changes button when doing the review. This should prevent the PR from being merged.
What do y'all think?

@andreeaflorescu
Copy link
Member

@sboeuf I am a bit on the fence about this one. The thing is that you can make mistakes on rebases so someone should still look at the code to make sure you didn't introduce any bugs.

Ideally, you would need to re-approve it only when the PR has changes that were not rebase specific. GitHub helps with that by allowing you to click the update branch button that does rebases for you while keeping the approves. The problem is that with PRs that sit a lot in the queue before getting merged, you will have conflicts that GitHub doesn't know how to fix. The same happens for PRs that change lots of lines of code (like this one).

How about before taking a decision, we put some metrics in place to see how often it happens that we need re-approvals where they would not be necessary and take a data-driven decision? I personally don't feel comfortable with taking that decision now.

I would also move this conversation either in a community issue or on the email so that it doesn't get lost when this PR is merged.

@sboeuf
Copy link

sboeuf commented Mar 25, 2020

@andreeaflorescu

The thing is that you can make mistakes on rebases so someone should still look at the code to make sure you didn't introduce any bugs.

That's why we put our trust in the CI :)

How about before taking a decision, we put some metrics in place to see how often it happens that we need re-approvals where they would not be necessary and take a data-driven decision? I personally don't feel comfortable with taking that decision now.

Of course, there's no rush, but that's something I find a bit heavy in terms of process, and this PR is the perfect example, that's why I wanted to raise the question here.

I would also move this conversation either in a community issue or on the email so that it doesn't get lost when this PR is merged.

Sounds good!

@sameo sameo merged commit 2adddce into rust-vmm:master Mar 26, 2020
@alxiord alxiord deleted the cleanup branch March 26, 2020 15:26
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.

7 participants