build: Bump clap from 3.2.22 to 4.0.9

Bumps [clap](https://github.com/clap-rs/clap) from 3.2.22 to 4.0.9.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](clap-rs/clap@v3.2.22...v4.0.9)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Moving to the major version 4 introduced some breaking changes which had
to be handled manually.

Fixes #4709

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2022-10-04 16:52:43 +02:00 committed by Rob Bradford
parent 307cfeba27
commit 89677c3181
13 changed files with 153 additions and 212 deletions

35
Cargo.lock generated
View File

@ -130,26 +130,24 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "3.2.22"
version = "4.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750"
checksum = "30607dd93c420c6f1f80b544be522a0238a7db35e6a12968d28910983fee0df0"
dependencies = [
"atty",
"bitflags",
"clap_lex",
"indexmap",
"once_cell",
"strsim",
"termcolor",
"terminal_size",
"textwrap",
]
[[package]]
name = "clap_lex"
version = "0.2.4"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [
"os_str_bytes",
]
@ -378,12 +376,6 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hermit-abi"
version = "0.1.20"
@ -437,16 +429,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "indexmap"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]]
name = "instant"
version = "0.1.12"
@ -1169,15 +1151,6 @@ dependencies = [
"wait-timeout",
]
[[package]]
name = "textwrap"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16"
dependencies = [
"terminal_size",
]
[[package]]
name = "thiserror"
version = "1.0.37"

View File

@ -20,7 +20,7 @@ opt-level = "s"
[dependencies]
anyhow = "1.0.65"
api_client = { path = "api_client" }
clap = { version = "3.2.22", features = ["wrap_help","cargo"] }
clap = { version = "4.0.9", features = ["wrap_help","cargo","string"] }
epoll = "4.3.1"
event_monitor = { path = "event_monitor" }
hypervisor = { path = "hypervisor" }
@ -37,7 +37,7 @@ vmm-sys-util = "0.10.0"
vm-memory = "0.9.0"
[build-dependencies]
clap = { version = "3.2.22", features = ["cargo"] }
clap = { version = "4.0.9", features = ["cargo"] }
# List of patched crates
[patch.crates-io]

41
fuzz/Cargo.lock generated
View File

@ -67,12 +67,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bincode"
version = "1.3.3"
@ -130,26 +124,24 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "3.2.22"
version = "4.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750"
checksum = "30607dd93c420c6f1f80b544be522a0238a7db35e6a12968d28910983fee0df0"
dependencies = [
"atty",
"bitflags",
"clap_lex",
"indexmap",
"once_cell",
"strsim",
"termcolor",
"terminal_size",
"textwrap",
]
[[package]]
name = "clap_lex"
version = "0.2.4"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [
"os_str_bytes",
]
@ -334,12 +326,6 @@ dependencies = [
"wasi",
]
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hermit-abi"
version = "0.1.20"
@ -384,16 +370,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "indexmap"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]]
name = "io-lifetimes"
version = "0.7.3"
@ -779,15 +755,6 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "textwrap"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16"
dependencies = [
"terminal_size",
]
[[package]]
name = "thiserror"
version = "1.0.37"

View File

@ -6,7 +6,7 @@ edition = "2021"
build = "build.rs"
[dependencies]
clap = { version = "3.2.22", features = ["wrap_help","cargo"] }
clap = { version = "4.0.9", features = ["wrap_help","cargo"] }
dirs = "4.0.0"
serde = { version = "1.0.145", features = ["rc", "derive"] }
serde_json = "1.0.85"
@ -15,4 +15,4 @@ thiserror = "1.0.37"
wait-timeout = "0.2.0"
[build-dependencies]
clap = { version = "3.2.22", features = ["cargo"] }
clap = { version = "4.0.9", features = ["cargo"] }

View File

@ -10,7 +10,7 @@ extern crate clap;
mod performance_tests;
use clap::{Arg, Command as ClapCommand};
use clap::{Arg, ArgAction, Command as ClapCommand};
use performance_tests::*;
use serde::{Deserialize, Serialize};
use std::{
@ -503,29 +503,28 @@ fn main() {
Arg::new("test-filter")
.long("test-filter")
.help("Filter metrics tests to run based on provided keywords")
.multiple_occurrences(true)
.takes_value(true)
.num_args(1)
.required(false),
)
.arg(
Arg::new("list-tests")
.long("list-tests")
.help("Print the list of availale metrics tests")
.multiple_occurrences(true)
.takes_value(false)
.num_args(0)
.action(ArgAction::SetTrue)
.required(false),
)
.arg(
Arg::new("report-file")
.long("report-file")
.help("Report file. Standard error is used if not specified")
.takes_value(true),
.num_args(1),
)
.arg(
Arg::new("iterations")
.long("iterations")
.help("Override number of test iterations")
.takes_value(true),
.num_args(1),
)
.get_matches();
@ -537,7 +536,7 @@ fn main() {
.filter(|t| !(cfg!(target_arch = "aarch64") && t.name == "virtio_net_latency_us"))
.collect();
if cmd_arguments.is_present("list-tests") {
if cmd_arguments.get_flag("list-tests") {
for test in test_list.iter() {
println!("\"{}\" ({})", test.name, test.control);
}
@ -545,7 +544,7 @@ fn main() {
return;
}
let test_filter = match cmd_arguments.values_of("test-filter") {
let test_filter = match cmd_arguments.get_many::<String>("test-filter") {
Some(s) => s.collect(),
None => Vec::new(),
};
@ -557,7 +556,7 @@ fn main() {
let overrides = Arc::new(PerformanceTestOverrides {
test_iterations: cmd_arguments
.value_of("iterations")
.get_one::<String>("iterations")
.map(|s| s.parse())
.transpose()
.unwrap_or_default(),
@ -580,7 +579,7 @@ fn main() {
cleanup_tests();
let mut report_file: Box<dyn std::io::Write + Send> =
if let Some(file) = cmd_arguments.value_of("report-file") {
if let Some(file) = cmd_arguments.get_one::<String>("report-file") {
Box::new(
std::fs::File::create(std::path::Path::new(file))
.map_err(|e| {

View File

@ -9,7 +9,7 @@ extern crate clap;
use api_client::simple_api_command;
use api_client::simple_api_command_with_fds;
use api_client::Error as ApiClientError;
use clap::{Arg, ArgMatches, Command};
use clap::{Arg, ArgAction, ArgMatches, Command};
use option_parser::{ByteSized, ByteSizedParseError};
use std::fmt;
use std::io::Read;
@ -328,8 +328,8 @@ fn create_api_command(socket: &mut UnixStream, path: &str) -> Result<(), Error>
}
fn do_command(matches: &ArgMatches) -> Result<(), Error> {
let mut socket =
UnixStream::connect(matches.value_of("api-socket").unwrap()).map_err(Error::Connect)?;
let mut socket = UnixStream::connect(matches.get_one::<String>("api-socket").unwrap())
.map_err(Error::Connect)?;
match matches.subcommand_name() {
Some("info") => {
@ -343,27 +343,30 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("resize")
.unwrap()
.value_of("cpus"),
.get_one::<String>("cpus")
.map(|x| x as &str),
matches
.subcommand_matches("resize")
.unwrap()
.value_of("memory"),
.get_one::<String>("memory")
.map(|x| x as &str),
matches
.subcommand_matches("resize")
.unwrap()
.value_of("balloon"),
.get_one::<String>("balloon")
.map(|x| x as &str),
),
Some("resize-zone") => resize_zone_api_command(
&mut socket,
matches
.subcommand_matches("resize-zone")
.unwrap()
.value_of("id")
.get_one::<String>("id")
.unwrap(),
matches
.subcommand_matches("resize-zone")
.unwrap()
.value_of("size")
.get_one::<String>("size")
.unwrap(),
),
Some("add-device") => add_device_api_command(
@ -371,7 +374,7 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("add-device")
.unwrap()
.value_of("device_config")
.get_one::<String>("device_config")
.unwrap(),
),
Some("remove-device") => remove_device_api_command(
@ -379,7 +382,7 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("remove-device")
.unwrap()
.value_of("id")
.get_one::<String>("id")
.unwrap(),
),
Some("add-disk") => add_disk_api_command(
@ -387,7 +390,7 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("add-disk")
.unwrap()
.value_of("disk_config")
.get_one::<String>("disk_config")
.unwrap(),
),
Some("add-fs") => add_fs_api_command(
@ -395,7 +398,7 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("add-fs")
.unwrap()
.value_of("fs_config")
.get_one::<String>("fs_config")
.unwrap(),
),
Some("add-pmem") => add_pmem_api_command(
@ -403,7 +406,7 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("add-pmem")
.unwrap()
.value_of("pmem_config")
.get_one::<String>("pmem_config")
.unwrap(),
),
Some("add-net") => add_net_api_command(
@ -411,7 +414,7 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("add-net")
.unwrap()
.value_of("net_config")
.get_one::<String>("net_config")
.unwrap(),
),
Some("add-user-device") => add_user_device_api_command(
@ -419,7 +422,7 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("add-user-device")
.unwrap()
.value_of("device_config")
.get_one::<String>("device_config")
.unwrap(),
),
Some("add-vdpa") => add_vdpa_api_command(
@ -427,7 +430,7 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("add-vdpa")
.unwrap()
.value_of("vdpa_config")
.get_one::<String>("vdpa_config")
.unwrap(),
),
Some("add-vsock") => add_vsock_api_command(
@ -435,7 +438,7 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("add-vsock")
.unwrap()
.value_of("vsock_config")
.get_one::<String>("vsock_config")
.unwrap(),
),
Some("snapshot") => snapshot_api_command(
@ -443,7 +446,7 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("snapshot")
.unwrap()
.value_of("snapshot_config")
.get_one::<String>("snapshot_config")
.unwrap(),
),
Some("restore") => restore_api_command(
@ -451,7 +454,7 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("restore")
.unwrap()
.value_of("restore_config")
.get_one::<String>("restore_config")
.unwrap(),
),
Some("coredump") => coredump_api_command(
@ -459,7 +462,7 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("coredump")
.unwrap()
.value_of("coredump_config")
.get_one::<String>("coredump_config")
.unwrap(),
),
Some("send-migration") => send_migration_api_command(
@ -467,19 +470,19 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("send-migration")
.unwrap()
.value_of("send_migration_config")
.get_one::<String>("send_migration_config")
.unwrap(),
matches
.subcommand_matches("send-migration")
.unwrap()
.is_present("send_migration_local"),
.get_flag("send_migration_local"),
),
Some("receive-migration") => receive_migration_api_command(
&mut socket,
matches
.subcommand_matches("receive-migration")
.unwrap()
.value_of("receive_migration_config")
.get_one::<String>("receive_migration_config")
.unwrap(),
),
Some("create") => create_api_command(
@ -487,7 +490,7 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
matches
.subcommand_matches("create")
.unwrap()
.value_of("path")
.get_one::<String>("path")
.unwrap(),
),
Some(c) => simple_api_command(&mut socket, "PUT", c, None).map_err(Error::ApiClient),
@ -504,8 +507,7 @@ fn main() {
Arg::new("api-socket")
.long("api-socket")
.help("HTTP API socket path (UNIX domain socket).")
.takes_value(true)
.number_of_values(1)
.num_args(1)
.required(true),
)
.subcommand(
@ -587,22 +589,19 @@ fn main() {
Arg::new("cpus")
.long("cpus")
.help("New vCPUs count")
.takes_value(true)
.number_of_values(1),
.num_args(1),
)
.arg(
Arg::new("memory")
.long("memory")
.help("New memory size in bytes (supports K/M/G suffix)")
.takes_value(true)
.number_of_values(1),
.num_args(1),
)
.arg(
Arg::new("balloon")
.long("balloon")
.help("New balloon size in bytes (supports K/M/G suffix)")
.takes_value(true)
.number_of_values(1),
.num_args(1),
),
)
.subcommand(
@ -612,15 +611,13 @@ fn main() {
Arg::new("id")
.long("id")
.help("Memory zone identifier")
.takes_value(true)
.number_of_values(1),
.num_args(1),
)
.arg(
Arg::new("size")
.long("size")
.help("New memory zone size in bytes (supports K/M/G suffix)")
.takes_value(true)
.number_of_values(1),
.num_args(1),
),
)
.subcommand(Command::new("resume").about("Resume the VM"))
@ -661,7 +658,8 @@ fn main() {
.arg(
Arg::new("send_migration_local")
.long("local")
.takes_value(false),
.num_args(0)
.action(ArgAction::SetTrue),
),
)
.subcommand(

View File

@ -8,7 +8,7 @@ extern crate clap;
#[macro_use]
extern crate event_monitor;
use clap::{Arg, ArgGroup, ArgMatches, Command};
use clap::{Arg, ArgAction, ArgGroup, ArgMatches, Command};
use libc::EFD_NONBLOCK;
use log::LevelFilter;
use option_parser::OptionParser;
@ -124,11 +124,7 @@ fn prepare_default_values() -> (String, String, String) {
(default_vcpus, default_memory, default_rng)
}
fn create_app<'a>(
default_vcpus: &'a str,
default_memory: &'a str,
default_rng: &'a str,
) -> Command<'a> {
fn create_app(default_vcpus: String, default_memory: String, default_rng: String) -> Command {
let app = Command::new("cloud-hypervisor")
// 'BUILT_VERSION' is set by the build script 'build.rs' at
// compile time
@ -157,7 +153,7 @@ fn create_app<'a>(
.help(
"num_pci_segments=<num_pci_segments>,iommu_segments=<list_of_segments>,serial_number=<dmi_device_serial_number>,uuid=<dmi_device_uuid>,oem_strings=<list_of_strings>",
)
.takes_value(true)
.num_args(1)
.group("vm-config"),
)
.arg(
@ -188,15 +184,14 @@ fn create_app<'a>(
hotplugged_size=<hotplugged_memory_size>,\
prefault=on|off\"",
)
.takes_value(true)
.min_values(1)
.num_args(1..)
.group("vm-config"),
)
.arg(
Arg::new("firmware")
.long("firmware")
.help("Path to firmware that is loaded in an architectural specific way")
.takes_value(true)
.num_args(1)
.group("vm-config"),
)
.arg(
@ -206,37 +201,35 @@ fn create_app<'a>(
"Path to kernel to load. This may be a kernel or firmware that supports a PVH \
entry point (e.g. vmlinux) or architecture equivalent",
)
.takes_value(true)
.num_args(1)
.group("vm-config"),
)
.arg(
Arg::new("initramfs")
.long("initramfs")
.help("Path to initramfs image")
.takes_value(true)
.num_args(1)
.group("vm-config"),
)
.arg(
Arg::new("cmdline")
.long("cmdline")
.help("Kernel command line")
.takes_value(true)
.num_args(1)
.group("vm-config"),
)
.arg(
Arg::new("disk")
.long("disk")
.help(config::DiskConfig::SYNTAX)
.takes_value(true)
.min_values(1)
.num_args(1..)
.group("vm-config"),
)
.arg(
Arg::new("net")
.long("net")
.help(config::NetConfig::SYNTAX)
.takes_value(true)
.min_values(1)
.num_args(1..)
.group("vm-config"),
)
.arg(
@ -252,23 +245,21 @@ fn create_app<'a>(
Arg::new("balloon")
.long("balloon")
.help(config::BalloonConfig::SYNTAX)
.takes_value(true)
.num_args(1)
.group("vm-config"),
)
.arg(
Arg::new("fs")
.long("fs")
.help(config::FsConfig::SYNTAX)
.takes_value(true)
.min_values(1)
.num_args(1..)
.group("vm-config"),
)
.arg(
Arg::new("pmem")
.long("pmem")
.help(config::PmemConfig::SYNTAX)
.takes_value(true)
.min_values(1)
.num_args(1..)
.group("vm-config"),
)
.arg(
@ -291,53 +282,49 @@ fn create_app<'a>(
Arg::new("device")
.long("device")
.help(config::DeviceConfig::SYNTAX)
.takes_value(true)
.min_values(1)
.num_args(1..)
.group("vm-config"),
)
.arg(
Arg::new("user-device")
.long("user-device")
.help(config::UserDeviceConfig::SYNTAX)
.takes_value(true)
.min_values(1)
.num_args(1..)
.group("vm-config"),
)
.arg(
Arg::new("vdpa")
.long("vdpa")
.help(config::VdpaConfig::SYNTAX)
.takes_value(true)
.min_values(1)
.num_args(1..)
.group("vm-config"),
)
.arg(
Arg::new("vsock")
.long("vsock")
.help(config::VsockConfig::SYNTAX)
.takes_value(true)
.number_of_values(1)
.num_args(1)
.group("vm-config"),
)
.arg(
Arg::new("numa")
.long("numa")
.help(config::NumaConfig::SYNTAX)
.takes_value(true)
.min_values(1)
.num_args(1..)
.group("vm-config"),
)
.arg(
Arg::new("watchdog")
.long("watchdog")
.help("Enable virtio-watchdog")
.takes_value(false)
.num_args(0)
.action(ArgAction::SetTrue)
.group("vm-config"),
)
.arg(
Arg::new("v")
.short('v')
.multiple_occurrences(true)
.action(ArgAction::Count)
.help("Sets the level of debugging output")
.group("logging"),
)
@ -345,39 +332,35 @@ fn create_app<'a>(
Arg::new("log-file")
.long("log-file")
.help("Log file. Standard error is used if not specified")
.takes_value(true)
.min_values(1)
.num_args(1)
.group("logging"),
)
.arg(
Arg::new("api-socket")
.long("api-socket")
.help("HTTP API socket (UNIX domain socket): path=</path/to/a/file> or fd=<fd>.")
.takes_value(true)
.min_values(1)
.num_args(1)
.group("vmm-config"),
)
.arg(
Arg::new("event-monitor")
.long("event-monitor")
.help("File to report events on: path=</path/to/a/file> or fd=<fd>")
.takes_value(true)
.min_values(1)
.num_args(1)
.group("vmm-config"),
)
.arg(
Arg::new("restore")
.long("restore")
.help(config::RestoreConfig::SYNTAX)
.takes_value(true)
.min_values(1)
.num_args(1)
.group("vmm-config"),
)
.arg(
Arg::new("seccomp")
.long("seccomp")
.takes_value(true)
.possible_values(["true", "false", "log"])
.num_args(1)
.value_parser(["true", "false", "log"])
.default_value("true"),
);
@ -386,8 +369,7 @@ fn create_app<'a>(
Arg::new("sgx-epc")
.long("sgx-epc")
.help(config::SgxEpcConfig::SYNTAX)
.takes_value(true)
.min_values(1)
.num_args(1..)
.group("vm-config"),
);
@ -396,7 +378,7 @@ fn create_app<'a>(
Arg::new("gdb")
.long("gdb")
.help("GDB socket (UNIX domain socket): path=</path/to/a/file>")
.takes_value(true)
.num_args(1)
.group("vmm-config"),
);
@ -404,7 +386,7 @@ fn create_app<'a>(
}
fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
let log_level = match cmd_arguments.occurrences_of("v") {
let log_level = match cmd_arguments.get_count("v") {
0 => LevelFilter::Warn,
1 => LevelFilter::Info,
2 => LevelFilter::Debug,
@ -412,7 +394,7 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
};
let log_file: Box<dyn std::io::Write + Send> = if let Some(file) =
cmd_arguments.value_of("log-file")
cmd_arguments.get_one::<String>("log-file")
{
Box::new(std::fs::File::create(std::path::Path::new(file)).map_err(Error::LogFileCreation)?)
} else {
@ -427,7 +409,7 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
.map_err(Error::LoggerSetup)?;
let (api_socket_path, api_socket_fd) =
if let Some(socket_config) = cmd_arguments.value_of("api-socket") {
if let Some(socket_config) = cmd_arguments.get_one::<String>("api-socket") {
let mut parser = OptionParser::new();
parser.add("path").add("fd");
parser.parse(socket_config).unwrap_or_default();
@ -441,7 +423,9 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
(Some(path), None)
} else {
(
cmd_arguments.value_of("api-socket").map(|s| s.to_string()),
cmd_arguments
.get_one::<String>("api-socket")
.map(|s| s.to_string()),
None,
)
}
@ -449,7 +433,7 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
(None, None)
};
if let Some(monitor_config) = cmd_arguments.value_of("event-monitor") {
if let Some(monitor_config) = cmd_arguments.get_one::<String>("event-monitor") {
let mut parser = OptionParser::new();
parser.add("path").add("fd");
parser
@ -478,8 +462,8 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
let api_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::CreateApiEventFd)?;
let http_sender = api_request_sender.clone();
let seccomp_action = if let Some(seccomp_value) = cmd_arguments.value_of("seccomp") {
match seccomp_value {
let seccomp_action = if let Some(seccomp_value) = cmd_arguments.get_one::<String>("seccomp") {
match seccomp_value as &str {
"true" => SeccompAction::Trap,
"false" => SeccompAction::Allow,
"log" => SeccompAction::Log,
@ -529,7 +513,7 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
let hypervisor = hypervisor::new().map_err(Error::CreateHypervisor)?;
#[cfg(feature = "guest_debug")]
let gdb_socket_path = if let Some(gdb_config) = cmd_arguments.value_of("gdb") {
let gdb_socket_path = if let Some(gdb_config) = cmd_arguments.get_one::<String>("gdb") {
let mut parser = OptionParser::new();
parser.add("path");
parser.parse(gdb_config).map_err(Error::ParsingGdb)?;
@ -566,7 +550,7 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
.map_err(Error::StartVmmThread)?;
let payload_present =
cmd_arguments.is_present("kernel") || cmd_arguments.is_present("firmware");
cmd_arguments.contains_id("kernel") || cmd_arguments.contains_id("firmware");
if payload_present {
let vm_params = config::VmParams::from_arg_matches(&cmd_arguments);
@ -581,7 +565,7 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
)
.map_err(Error::VmCreate)?;
vmm::api::vm_boot(api_evt.try_clone().unwrap(), sender).map_err(Error::VmBoot)?;
} else if let Some(restore_params) = cmd_arguments.value_of("restore") {
} else if let Some(restore_params) = cmd_arguments.get_one::<String>("restore") {
vmm::api::vm_restore(
api_evt.try_clone().unwrap(),
api_request_sender,
@ -603,7 +587,7 @@ fn main() {
let _ = unsafe { libc::umask(0o077) };
let (default_vcpus, default_memory, default_rng) = prepare_default_values();
let cmd_arguments = create_app(&default_vcpus, &default_memory, &default_rng).get_matches();
let cmd_arguments = create_app(default_vcpus, default_memory, default_rng).get_matches();
let exit_code = match start_vmm(cmd_arguments) {
Ok(path) => {
path.map(|s| std::fs::remove_file(s).ok());
@ -638,7 +622,7 @@ mod unit_tests {
fn get_vm_config_from_vec(args: &[&str]) -> VmConfig {
let (default_vcpus, default_memory, default_rng) = prepare_default_values();
let cmd_arguments =
create_app(&default_vcpus, &default_memory, &default_rng).get_matches_from(args);
create_app(default_vcpus, default_memory, default_rng).get_matches_from(args);
let vm_params = VmParams::from_arg_matches(&cmd_arguments);

View File

@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
block_util = { path = "../block_util" }
clap = { version = "3.2.22", features = ["wrap_help","cargo"] }
clap = { version = "4.0.9", features = ["wrap_help","cargo"] }
env_logger = "0.9.1"
epoll = "4.3.1"
libc = "0.2.134"
@ -21,4 +21,4 @@ vm-memory = "0.9.0"
vmm-sys-util = "0.10.0"
[build-dependencies]
clap = { version = "3.2.22", features = ["cargo"] }
clap = { version = "4.0.9", features = ["cargo"] }

View File

@ -26,11 +26,11 @@ fn main() {
Arg::new("block-backend")
.long("block-backend")
.help(vhost_user_block::SYNTAX)
.takes_value(true)
.num_args(1)
.required(true),
)
.get_matches();
let backend_command = cmd_arguments.value_of("block-backend").unwrap();
let backend_command = cmd_arguments.get_one::<String>("block-backend").unwrap();
start_block_backend(backend_command);
}

View File

@ -5,7 +5,7 @@ authors = ["The Cloud Hypervisor Authors"]
edition = "2021"
[dependencies]
clap = { version = "3.2.22", features = ["wrap_help","cargo"] }
clap = { version = "4.0.9", features = ["wrap_help","cargo"] }
env_logger = "0.9.1"
epoll = "4.3.1"
libc = "0.2.134"
@ -19,4 +19,4 @@ vm-memory = "0.9.0"
vmm-sys-util = "0.10.0"
[build-dependencies]
clap = { version = "3.2.22", features = ["cargo"] }
clap = { version = "4.0.9", features = ["cargo"] }

View File

@ -23,11 +23,11 @@ fn main() {
Arg::new("net-backend")
.long("net-backend")
.help(vhost_user_net::SYNTAX)
.takes_value(true)
.num_args(1)
.required(true),
)
.get_matches();
let backend_command = cmd_arguments.value_of("net-backend").unwrap();
let backend_command = cmd_arguments.get_one::<String>("net-backend").unwrap();
start_net_backend(backend_command);
}

View File

@ -19,7 +19,7 @@ arc-swap = "1.5.1"
arch = { path = "../arch" }
bitflags = "1.3.2"
block_util = { path = "../block_util" }
clap = "3.2.22"
clap = "4.0.9"
devices = { path = "../devices" }
epoll = "4.3.1"
event_monitor = { path = "../event_monitor" }

View File

@ -387,32 +387,52 @@ pub struct VmParams<'a> {
impl<'a> VmParams<'a> {
pub fn from_arg_matches(args: &'a ArgMatches) -> Self {
// These .unwrap()s cannot fail as there is a default value defined
let cpus = args.value_of("cpus").unwrap();
let memory = args.value_of("memory").unwrap();
let memory_zones: Option<Vec<&str>> = args.values_of("memory-zone").map(|x| x.collect());
let rng = args.value_of("rng").unwrap();
let serial = args.value_of("serial").unwrap();
let firmware = args.value_of("firmware");
let kernel = args.value_of("kernel");
let initramfs = args.value_of("initramfs");
let cmdline = args.value_of("cmdline");
let disks: Option<Vec<&str>> = args.values_of("disk").map(|x| x.collect());
let net: Option<Vec<&str>> = args.values_of("net").map(|x| x.collect());
let console = args.value_of("console").unwrap();
let balloon = args.value_of("balloon");
let fs: Option<Vec<&str>> = args.values_of("fs").map(|x| x.collect());
let pmem: Option<Vec<&str>> = args.values_of("pmem").map(|x| x.collect());
let devices: Option<Vec<&str>> = args.values_of("device").map(|x| x.collect());
let user_devices: Option<Vec<&str>> = args.values_of("user-device").map(|x| x.collect());
let vdpa: Option<Vec<&str>> = args.values_of("vdpa").map(|x| x.collect());
let vsock: Option<&str> = args.value_of("vsock");
let cpus = args.get_one::<String>("cpus").unwrap();
let memory = args.get_one::<String>("memory").unwrap();
let memory_zones: Option<Vec<&str>> = args
.get_many::<String>("memory-zone")
.map(|x| x.map(|y| y as &str).collect());
let rng = args.get_one::<String>("rng").unwrap();
let serial = args.get_one::<String>("serial").unwrap();
let firmware = args.get_one::<String>("firmware").map(|x| x as &str);
let kernel = args.get_one::<String>("kernel").map(|x| x as &str);
let initramfs = args.get_one::<String>("initramfs").map(|x| x as &str);
let cmdline = args.get_one::<String>("cmdline").map(|x| x as &str);
let disks: Option<Vec<&str>> = args
.get_many::<String>("disk")
.map(|x| x.map(|y| y as &str).collect());
let net: Option<Vec<&str>> = args
.get_many::<String>("net")
.map(|x| x.map(|y| y as &str).collect());
let console = args.get_one::<String>("console").unwrap();
let balloon = args.get_one::<String>("balloon").map(|x| x as &str);
let fs: Option<Vec<&str>> = args
.get_many::<String>("fs")
.map(|x| x.map(|y| y as &str).collect());
let pmem: Option<Vec<&str>> = args
.get_many::<String>("pmem")
.map(|x| x.map(|y| y as &str).collect());
let devices: Option<Vec<&str>> = args
.get_many::<String>("device")
.map(|x| x.map(|y| y as &str).collect());
let user_devices: Option<Vec<&str>> = args
.get_many::<String>("user-device")
.map(|x| x.map(|y| y as &str).collect());
let vdpa: Option<Vec<&str>> = args
.get_many::<String>("vdpa")
.map(|x| x.map(|y| y as &str).collect());
let vsock: Option<&str> = args.get_one::<String>("vsock").map(|x| x as &str);
#[cfg(target_arch = "x86_64")]
let sgx_epc: Option<Vec<&str>> = args.values_of("sgx-epc").map(|x| x.collect());
let numa: Option<Vec<&str>> = args.values_of("numa").map(|x| x.collect());
let watchdog = args.is_present("watchdog");
let platform = args.value_of("platform");
let sgx_epc: Option<Vec<&str>> = args
.get_many::<String>("sgx-epc")
.map(|x| x.map(|y| y as &str).collect());
let numa: Option<Vec<&str>> = args
.get_many::<String>("numa")
.map(|x| x.map(|y| y as &str).collect());
let watchdog = args.get_flag("watchdog");
let platform = args.get_one::<String>("platform").map(|x| x as &str);
#[cfg(feature = "guest_debug")]
let gdb = args.is_present("gdb");
let gdb = args.contains_id("gdb");
VmParams {
cpus,
memory,