-
Notifications
You must be signed in to change notification settings - Fork 2k
Get machine config V2 #248
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
andreeaflorescu
merged 4 commits into
firecracker-microvm:master
from
andreeaflorescu:get_machine_config_v2
May 8, 2018
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
[package] | ||
name = "data_model" | ||
version = "0.1.0" | ||
authors = ["The Chromium OS Authors"] | ||
authors = ["Amazon firecracker team <[email protected]>"] | ||
|
||
[dependencies] | ||
serde = "=1.0.27" | ||
serde_derive = "=1.0.27" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,5 @@ | ||
// Copyright 2017 The Chromium OS Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
extern crate serde; | ||
#[macro_use] | ||
extern crate serde_derive; | ||
|
||
/// Types for which it is safe to initialize from raw data. | ||
/// | ||
/// A type `T` is `DataInit` if and only if it can be initialized by reading its contents from a | ||
/// byte array. This is generally true for all plain-old-data structs. It is notably not true for | ||
/// any type that includes a reference. | ||
/// | ||
/// Implementing this trait guarantees that it is safe to instantiate the struct with random data. | ||
pub unsafe trait DataInit: Copy + Send + Sync {} | ||
|
||
// All intrinsic types and arays of intrinsic types are DataInit. They are just numbers. | ||
macro_rules! array_data_init { | ||
($T:ty, $($N:expr)+) => { | ||
$( | ||
unsafe impl DataInit for [$T; $N] {} | ||
)+ | ||
} | ||
} | ||
macro_rules! data_init_type { | ||
($T:ty) => { | ||
unsafe impl DataInit for $T {} | ||
array_data_init! { | ||
$T, | ||
0 1 2 3 4 5 6 7 8 9 | ||
10 11 12 13 14 15 16 17 18 19 | ||
20 21 22 23 24 25 26 27 28 29 | ||
30 31 32 | ||
} | ||
} | ||
} | ||
data_init_type!(u8); | ||
data_init_type!(u16); | ||
data_init_type!(u32); | ||
data_init_type!(u64); | ||
data_init_type!(usize); | ||
data_init_type!(i8); | ||
data_init_type!(i16); | ||
data_init_type!(i32); | ||
data_init_type!(i64); | ||
data_init_type!(isize); | ||
|
||
pub mod endian; | ||
pub use endian::*; | ||
|
||
pub mod volatile_memory; | ||
pub use volatile_memory::*; | ||
pub mod vm; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] | ||
pub struct MachineConfiguration { | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub vcpu_count: Option<u8>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub mem_size_mib: Option<usize>, | ||
} | ||
|
||
impl Default for MachineConfiguration { | ||
fn default() -> Self { | ||
MachineConfiguration { | ||
vcpu_count: Some(1), | ||
mem_size_mib: Some(128), | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod machine_config; | ||
|
||
pub use vm::machine_config::MachineConfiguration; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "memory_model" | ||
version = "0.1.0" | ||
authors = ["The Chromium OS Authors"] | ||
|
||
[dependencies] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I have a concern here that it might be confusing for open source developers to find a
data_model
crate in Firecracker and another one in crosvm, which Firecracker is loosely based upon, but which contains different stuff. It would be even more confusing if the contents of crosvm'sdata_model
are moved in a differently named crate in Firecracker (likememory_model
). I understand thatmemory_model
is a good name for memory related structs, but I'd prefer to keep naming consistency.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.
While this makes sense, I don't agree we should bend over backwards to keep as close to crossvm as possible.
I guess we could avoid renaming data_model->memory_model if we find an appropriate name for the data model stuff we want to put in data_model 😆
But personally, I'm fine with the change proposed here.
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.
The plan is to remove the memory_model crate all together. From that crate only the volatile_memory.rs and some definitions from mod.rs are actually used. The plan would be to moved those to a crate where they actually belong. Might be sys_util (as Diana suggested) or something else.