-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Improve command-line arguments #1862
Improve command-line arguments #1862
Conversation
I'm sorry for the collision. I really liked your idea about using BTreeMap so I incorporated it in my commit. It made my code much simpler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @edigaryev! Thanks for the pull request 😄
While some of the functionality that is in this PR was merged with #1861, we can keep the test for mknod_and_own_dev
if you want to rebase this commit on top of the current changes.
@ioanachirca should I bump the |
src/jailer/src/env.rs
Outdated
let good_arg_vals = ArgVals { | ||
node: "1", | ||
id: "bd65600d-8669-4903-8a14-af88203add38", | ||
exec_file: "/proc/cpuinfo", | ||
uid: "1001", | ||
gid: "1002", | ||
chroot_base: "/", | ||
netns: Some("zzzns"), | ||
daemonize: true, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be replaced with let good_arg_vals = ArgVals::new()
;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See 1847636.
src/jailer/src/env.rs
Outdated
// Ensure TUN device node is created with correct major/minor numbers. | ||
let tun = b"/dev/net/tun-test\0"; | ||
let tun_str = CStr::from_bytes_with_nul(tun).unwrap().to_str().unwrap(); | ||
fs::remove_file(tun_str).or_else(skip_not_found).unwrap(); | ||
env.mknod_and_own_dev(tun, DEV_NET_TUN_MAJOR, DEV_NET_TUN_MINOR) | ||
.unwrap(); | ||
|
||
let metadata = File::open(tun_str).unwrap().metadata().unwrap(); | ||
assert_eq!(metadata.file_type().is_char_device(), true); | ||
assert_eq!(get_major(metadata.rdev()), DEV_NET_TUN_MAJOR); | ||
assert_eq!(get_minor(metadata.rdev()), DEV_NET_TUN_MINOR); | ||
assert_eq!(metadata.permissions().mode(), expected_device_permissions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part and the next one look very similar, only the device and its minor and major numbers differ. You can reduce the duplicate code by using a for
, something like this:
let tun = b"/dev/net/tun-test\0";
let kvm = b"/dev/kvm-test\0";
let dev_infos: Vec<(&[u8], u32, u32)> = vec![
(tun, DEV_NET_TUN_MAJOR, DEV_NET_TUN_MINOR),
(kvm, DEV_KVM_MAJOR, DEV_KVM_MINOR),
];
for (dev, major, minor) in dev_infos {
let dev_str = CStr::from_bytes_with_nul(dev).unwrap().to_str().unwrap();
...
}
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This looks way better. See 1847636.
Hi, @edigaryev! The coverage should be indeed updated with the new values, I suggest you to wait for the CI to finish in order to see also the coverage value for AMD. |
Squashed into 1847636.
Applied 50/72 to 1847636. I was initially trying to replicate the convention from Perhaps the Contribution Quality Standards can be updated to reflect this practice? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I have two more nits.
Also, please don't forget to update the coverage target value in test_coverage.py
.
And one more thing: there is no need to add me and Ioana as co-authors to your commit; you can remove those lines. It's your work and we're here to help you :D.
You mean we should add the 50/72 rule explicitly there? It is indeed pretty hidden here. |
Thanks, totally missed that. Also, the Buildkite runner seems to be stuck on |
Will fix it soon. |
@edigaryev Can you please update AMD coverage too and we will re-approve after that? |
The test ensures that Env.mknod_and_own_dev() creates character devices with correct major/minor numbers and permissions. Signed-off-by: Nikolay Edigaryev <edigaryev@gmail.com>
Reason for This PR
#1688
Description of Changes
#1688, with the following additions:
--start-time-us
and--start-time-cpu-us
, fixedstart-time-cpu-us
typo...and with the exception for:
See #1688 (comment).
rust-vmm
.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
[Reviewer TODO: Verify that these criteria are met. Request changes if not]
git commit -s
).unsafe
code is properly documented.firecracker/swagger.yaml
.CHANGELOG.md
.