Skip to content

Rust 1.39 Update + Spring Cleaning #1419

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

Merged
merged 4 commits into from
Nov 29, 2019

Conversation

dhrgit
Copy link
Contributor

@dhrgit dhrgit commented Nov 22, 2019

Reason for This PR

Tidy is good, tidy is love.

Description of Changes

  • workspace: all sources are now placed in their respective crates, under /src/<crate>;
  • workspace: unified the jailer source under a single bin crate /src/jailer; removed jailer dependency from the firecracker crate;
  • workspace: configured the build artifacts dir via .cargo/config;
  • devctr: removed env variable used to override the cargo build dir; updated to Rust toolchain 1.39;
  • clippy: added safety doc comments;
  • vsock: switched to using zeroed memory for the TX buffer, instead of mem::uninitialized, since the latter is both unsafe and deprecated by Rust 1.39;
  • also fixed up some whitespace errors.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.

PR Checklist

[Author TODO: Meet these criteria. Where there are two options, keep one.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]

  • All commits in this PR are signed (git commit -s).
  • Either this PR is linked to an issue, or, the reason for this PR is
    clearly provided.
  • The description of changes is clear and encompassing.
  • Either no docs need to be updated as part of this PR, or, the required
    doc changes are included in this PR. Docs in scope are all *.md files
    located either in the repository root, or in the docs/ directory.
  • Either no code has been touched, or, code-level documentation for touched
    code is included in this PR.
  • Either no API changes are included in this PR, or, the API changes are
    reflected in firecracker/swagger.yaml.
  • Either the changes in this PR have no user impact, or, the changes in
    this PR have user impact and have been added to the CHANGELOG.md file.
  • Either no new unsafe code has been added, or, the newly added unsafe
    code is unavoidable and properly documented.

@dhrgit dhrgit self-assigned this Nov 22, 2019
@dhrgit dhrgit force-pushed the cleanup-139 branch 2 times, most recently from d9a225a to 42a1bf9 Compare November 24, 2019 16:30
@andreeaflorescu
Copy link
Member

Changes LGTM. I'll approve this once the arm build is fixed as well.

@acatangiu
Copy link
Contributor

Do you have a quick reference resource you can link that explains why moving the crates under /src is tidy while the current state is not?

@andreeaflorescu
Copy link
Member

My personal take on this is I that it makes more sense as the source code is clearly separated from the documentation and other utilities. It is much easier to navigate through misc docs and tools as they don't mingle with rust code as well.

@dhrgit
Copy link
Contributor Author

dhrgit commented Nov 25, 2019

Do you have a quick reference resource you can link that explains why moving the crates under /src is tidy while the current state is not?

I don't have one handy. However, you can look at it like this: just as a crate is structured using a src dir for the sources, a target dir for the build artifacts, and the root for support files (such as Cargo.toml), so should a workspace be. I.e. sources go under src, integration tests go under tests, documentation goes under docs, and so on.

Also, in this particular case, it's more tidy because this arrangement enables decoupling the firecracker and jailer crates. In the previous layout, the jailer main was part of the firecracker crate, while the jailer core lived in its own crate. Now, they are two independent bin (executable) crates.

@acatangiu
Copy link
Contributor

Makes sense. I thought we enable some Cargo magic as well (that we were previously missing).

@raduweiss
Copy link
Contributor

My esthetics only opinion is "+100".

acatangiu
acatangiu previously approved these changes Nov 26, 2019
Copy link
Contributor

@acatangiu acatangiu left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@dianpopa dianpopa left a comment

Choose a reason for hiding this comment

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

I do like this workspace reorganization better than the older one 👍 However, given that this PR is changing in an impactful way how Firecracker will look from now on, I think the entire team should give their approval on this or at least be informed of it before merge in order not to be taken by surprise.


[dev-dependencies]
tempfile = ">=3.0.2"
[workspace]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: your commit message misspells "workspace" twice (i.e. worspace)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FIxed.

@@ -39,9 +39,6 @@ def test_unittests(test_session_root_path, target):
if MACHINE == "x86_64":
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a miss as I do not think there is a reason why we would not want to test all features on all architectures.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A miss indeed. Fixed.

/// # Safety
///
/// This is unsafe because the structs are initialized to unverified data read from the input.
/// `read_struct_slice` should only be called for plain old data structs. It is not endian safe.
// This lint check is now deprecated - https://github.com/rust-lang/rust-clippy/pull/3478/files
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment still valid? What lint check is it refferring to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed. Looks like that comment had been left behind when the clippy override was removed.

@sandreim sandreim self-requested a review November 27, 2019 11:06
Copy link
Contributor

@sandreim sandreim left a comment

Choose a reason for hiding this comment

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

I think this re-org is aesthetically pleasing. 👌

dianpopa
dianpopa previously approved these changes Nov 27, 2019
@dhrgit dhrgit dismissed stale reviews from andreeaflorescu and dianpopa via e9d4b06 November 27, 2019 17:46
Tidied up the cargo workspace a bit:
- all sources are now placed in their respective crates, under
  `/src/<crate>`;
- unified the jailer sources under the self-contained `/src/jailer` bin
  crate;
- fixed `utils/src/lib.rs` copyright + some nitty tidying up;
- arch-gated the `cpuid` crate to x86_64;
- fixed some whitespace errors.

Signed-off-by: Dan Horobeanu <[email protected]>
- cargo: configured the build dir via `.cargo/config`;
- devctr: removed env variable used to override build dir; updated rust
  toolchain to 1.39;
- clippy: added safety doc comments;
- vsock: switched to using zeroed memory for the TX buffer, instead of
  `mem::uninitialized`, since the latter is both unsafe and deprecated
  by Rust 1.39.

Signed-off-by: Dan Horobeanu <[email protected]>
Fixed a bunch of whitespace errors scattered throughout the repo.

Signed-off-by: Dan Horobeanu <[email protected]>
Some of our crates were pinning their dependency versions. This was
redundant, since we are using a versioned, worskspace-wide, Cargo.lock
which we update with every release. It also resulted in `cargo update`
not updating the depended-upon crates to their latest versions.

This commit switches all dependecy version specifications to the latest
version (i.e. the ">=<version>" syntax), and also updates Cargo.lock
(via `cargo update`).

Signed-off-by: Dan Horobeanu <[email protected]>
@acatangiu acatangiu merged commit 777e366 into firecracker-microvm:master Nov 29, 2019
kzys added a commit to kzys/firecracker-containerd that referenced this pull request Jan 24, 2020
- Rust 1.35 cannot parse Firecracker's Cargo.lock somehow
- While Rust's latest release is 1.40.0, we'd like to keep in sync
  with Firecracker upstream.

firecracker-microvm/firecracker#1419

Signed-off-by: Kazuyoshi Kato <[email protected]>
kzys added a commit to kzys/firecracker-containerd that referenced this pull request Jan 24, 2020
- Rust 1.35 cannot parse Firecracker's Cargo.lock somehow
- While Rust's latest release is 1.40.0, we'd like to keep in sync
  with Firecracker upstream.

firecracker-microvm/firecracker#1419

Signed-off-by: Kazuyoshi Kato <[email protected]>
kzys added a commit to kzys/firecracker-containerd that referenced this pull request Jan 28, 2020
- Rust 1.35 cannot parse Firecracker's Cargo.lock somehow
- While Rust's latest release is 1.40.0, we'd like to keep in sync
  with Firecracker upstream.

firecracker-microvm/firecracker#1419

Signed-off-by: Kazuyoshi Kato <[email protected]>
kzys added a commit to kzys/firecracker-containerd that referenced this pull request Feb 5, 2020
- Rust 1.35 cannot parse Firecracker's Cargo.lock somehow
- While Rust's latest release is 1.40.0, we'd like to keep in sync
  with Firecracker upstream.

firecracker-microvm/firecracker#1419

Signed-off-by: Kazuyoshi Kato <[email protected]>
kzys added a commit to kzys/firecracker-containerd that referenced this pull request Feb 10, 2020
- Rust 1.35 cannot parse Firecracker's Cargo.lock somehow
- While Rust's latest release is 1.40.0, we'd like to keep in sync
  with Firecracker upstream.

firecracker-microvm/firecracker#1419

Signed-off-by: Kazuyoshi Kato <[email protected]>
kzys added a commit to kzys/firecracker-containerd that referenced this pull request Feb 13, 2020
- Rust 1.35 cannot parse Firecracker's Cargo.lock somehow
- While Rust's latest release is 1.40.0, we'd like to keep in sync
  with Firecracker upstream.

firecracker-microvm/firecracker#1419

Signed-off-by: Kazuyoshi Kato <[email protected]>
kzys added a commit to kzys/firecracker-containerd that referenced this pull request Feb 17, 2020
- Rust 1.35 cannot parse Firecracker's Cargo.lock somehow
- While Rust's latest release is 1.40.0, we'd like to keep in sync
  with Firecracker upstream.

firecracker-microvm/firecracker#1419

Signed-off-by: Kazuyoshi Kato <[email protected]>
kzys added a commit to kzys/firecracker-containerd that referenced this pull request Feb 18, 2020
- Rust 1.35 cannot parse Firecracker's Cargo.lock somehow
- While Rust's latest release is 1.40.0, we'd like to keep in sync
  with Firecracker upstream.

firecracker-microvm/firecracker#1419

Signed-off-by: Kazuyoshi Kato <[email protected]>
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.

6 participants