Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
471 changes: 362 additions & 109 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license = "Apache-2.0 OR BSD-3-Clause"
[dependencies]
vmm = { path = "src/vmm" }
api = { path = "src/api" }
linux-loader = "0.13.0"

[workspace]
members = ["src/vm-vcpu-ref"]
Expand All @@ -21,5 +22,5 @@ lto = true
panic = "abort"

[patch.crates-io]
# TODO: Using this patch until a version > 4.0 gets published.
linux-loader = { git = "https://github.com/rust-vmm/linux-loader.git", rev = "9a9f071" }
# TODO: Update with https://github.com/rust-vmm/linux-loader.git hash of commit
# "add as_string() to the Cmdline crate"
4 changes: 2 additions & 2 deletions src/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ authors = ["rust-vmm AWS maintainers <[email protected]>"]
edition = "2018"

[dependencies]
clap = "3.2.17"
clap = "4.5.28"

vmm = { path = "../vmm" }

[dev-dependencies]
linux-loader = "0.4.0"
linux-loader = "0.13.0"
51 changes: 32 additions & 19 deletions src/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#![deny(missing_docs)]
use std::result;

use clap::{App, Arg};
use clap::{Arg, Command};
use vmm::VMMConfig;

/// Command line parser.
Expand All @@ -18,38 +18,45 @@ impl Cli {
///
/// * `cmdline_args` - command line arguments passed to the application.
pub fn launch(cmdline_args: Vec<&str>) -> result::Result<VMMConfig, String> {
let mut app = App::new(cmdline_args[0].to_string())
let mut app = Command::new("vmm-reference")
.arg(
Arg::with_name("memory")
Arg::new("memory")
.long("memory")
.takes_value(true)
.help("Guest memory configuration.\n\tFormat: \"size_mib=<u32>\""),
)
.arg(
Arg::with_name("vcpu")
Arg::new("vcpu")
.long("vcpu")
.takes_value(true)
.help("vCPU configuration.\n\tFormat: \"num=<u8>\""),
)
.arg(
Arg::with_name("kernel")
Arg::new("kernel")
.long("kernel")
.required(true)
.takes_value(true)
.help("Kernel configuration.\n\tFormat: \"path=<string>[,cmdline=<string>,kernel_load_addr=<u64>]\""),
)
.arg(
Arg::with_name("net")
Arg::new("net")
.long("net")
.takes_value(true)
.help("Network device configuration. \n\tFormat: \"tap=<string>\"")
)
.arg(
Arg::with_name("block")
Arg::new("block")
.long("block")
.required(false)
.takes_value(true)
.help("Block device configuration. \n\tFormat: \"path=<string>\"")
)
.arg(
Arg::new("dump-dtb")
.long("dump-dtb")
.required(false)
.help("If set, dump the DTB to a file")
)
.arg(
Arg::new("dtb")
.long("dtb")
.required(false)
.help("If set, takes as DTB the one at the specified path")
);

// Save the usage beforehand as a string, because `get_matches` consumes the `App`.
Expand All @@ -58,17 +65,19 @@ impl Cli {
let _ = app.write_long_help(&mut help_msg_buf);
let help_msg = String::from_utf8_lossy(&help_msg_buf);

let matches = app.get_matches_from_safe(cmdline_args).map_err(|e| {
let matches = app.try_get_matches_from(cmdline_args).map_err(|e| {
eprintln!("{}", help_msg);
format!("Invalid command line arguments: {}", e)
})?;

VMMConfig::builder()
.memory_config(matches.value_of("memory"))
.kernel_config(matches.value_of("kernel"))
.vcpu_config(matches.value_of("vcpu"))
.net_config(matches.value_of("net"))
.block_config(matches.value_of("block"))
.memory_config(matches.get_one::<String>("memory"))
.kernel_config(matches.get_one::<String>("kernel"))
.vcpu_config(matches.get_one::<String>("vcpu"))
.net_config(matches.get_one::<String>("net"))
.block_config(matches.get_one::<String>("block"))
.dump_dtb_config(matches.get_one::<String>("dump-dtb"))
.dtb_config(matches.get_one::<String>("dtb"))
.build()
.map_err(|e| format!("{:?}", e))
}
Expand Down Expand Up @@ -211,7 +220,7 @@ mod tests {
])
.is_err());

let mut foo_cmdline = Cmdline::new(4096);
let mut foo_cmdline = Cmdline::new(4096).unwrap();
foo_cmdline.insert_str("\"foo=bar bar=foo\"").unwrap();

// OK.
Expand All @@ -236,6 +245,8 @@ mod tests {
vcpu_config: VcpuConfig { num: 1 },
block_config: None,
net_config: None,
dump_dtb: None,
dtb: None,
}
);

Expand All @@ -252,6 +263,8 @@ mod tests {
vcpu_config: VcpuConfig { num: 1 },
block_config: None,
net_config: None,
dump_dtb: None,
dtb: None,
}
);
}
Expand Down
7 changes: 5 additions & 2 deletions src/arch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
vm-fdt = "0.2.0"
vm-memory = "0.7.0"
log = "0.4.21"
vm-fdt = "0.3.0"
vm-memory = "0.16.0"
kvm-ioctls = { git = "https://github.com/rust-vmm/kvm.git"}
kvm-bindings = { git = "https://github.com/rust-vmm/kvm.git", features = ["fam-wrappers"] }
Loading