diff --git a/Cargo.lock b/Cargo.lock index cb61f87ca..2673ba30e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,15 +33,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anyhow" version = "1.0.52" @@ -170,18 +161,19 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "2.34.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "d17bf219fcd37199b9a29e00ba65dfb8cd5b2688b7297ec14ff829c40ac50ca9" dependencies = [ - "ansi_term", "atty", "bitflags", + "indexmap", + "lazy_static", + "os_str_bytes", "strsim", - "term_size", + "termcolor", + "terminal_size", "textwrap", - "unicode-width", - "vec_map", ] [[package]] @@ -370,6 +362,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + [[package]] name = "hermit-abi" version = "0.1.20" @@ -417,6 +415,16 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "instant" version = "0.1.12" @@ -639,6 +647,15 @@ dependencies = [ name = "option_parser" version = "0.1.0" +[[package]] +name = "os_str_bytes" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" +dependencies = [ + "memchr", +] + [[package]] name = "parking_lot" version = "0.11.2" @@ -989,9 +1006,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" @@ -1016,16 +1033,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "term_size" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "termcolor" version = "1.1.2" @@ -1035,6 +1042,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "test_infra" version = "0.1.0" @@ -1049,12 +1066,11 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.11.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" dependencies = [ - "term_size", - "unicode-width", + "terminal_size", ] [[package]] @@ -1077,12 +1093,6 @@ dependencies = [ "syn", ] -[[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - [[package]] name = "unicode-xid" version = "0.2.2" @@ -1104,12 +1114,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "versionize" version = "0.1.6" diff --git a/Cargo.toml b/Cargo.toml index 7228cc07a..665b13ae7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ lto = true [dependencies] anyhow = "1.0.52" api_client = { path = "api_client" } -clap = { version = "2.34.0", features = ["wrap_help"] } +clap = { version = "3.0.0", features = ["wrap_help","cargo"] } epoll = "4.3.1" event_monitor = { path = "event_monitor" } hypervisor = { path = "hypervisor" } @@ -31,7 +31,7 @@ vmm-sys-util = "0.9.0" vm-memory = "0.7.0" [build-dependencies] -clap = { version = "2.34.0", features = ["wrap_help"] } +clap = { version = "3.0.0", features = ["wrap_help"] } # List of patched crates [patch.crates-io] diff --git a/src/bin/ch-remote.rs b/src/bin/ch-remote.rs index 282252f56..9d822512e 100644 --- a/src/bin/ch-remote.rs +++ b/src/bin/ch-remote.rs @@ -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::{App, AppSettings, Arg, ArgMatches, SubCommand}; +use clap::{App, AppSettings, Arg, ArgMatches}; use option_parser::{ByteSized, ByteSizedParseError}; use std::fmt; use std::os::unix::net::UnixStream; @@ -422,7 +422,7 @@ fn main() { .setting(AppSettings::SubcommandRequired) .about("Remotely control a cloud-hypervisor VMM.") .arg( - Arg::with_name("api-socket") + Arg::new("api-socket") .long("api-socket") .help("HTTP API socket path (UNIX domain socket).") .takes_value(true) @@ -430,97 +430,89 @@ fn main() { .required(true), ) .subcommand( - SubCommand::with_name("add-device") - .about("Add VFIO device") - .arg( - Arg::with_name("device_config") - .index(1) - .help(vmm::config::DeviceConfig::SYNTAX), - ), + App::new("add-device").about("Add VFIO device").arg( + Arg::new("device_config") + .index(1) + .help(vmm::config::DeviceConfig::SYNTAX), + ), ) .subcommand( - SubCommand::with_name("add-disk") - .about("Add block device") - .arg( - Arg::with_name("disk_config") - .index(1) - .help(vmm::config::DiskConfig::SYNTAX), - ), + App::new("add-disk").about("Add block device").arg( + Arg::new("disk_config") + .index(1) + .help(vmm::config::DiskConfig::SYNTAX), + ), ) .subcommand( - SubCommand::with_name("add-fs") + App::new("add-fs") .about("Add virtio-fs backed fs device") .arg( - Arg::with_name("fs_config") + Arg::new("fs_config") .index(1) .help(vmm::config::FsConfig::SYNTAX), ), ) .subcommand( - SubCommand::with_name("add-pmem") + App::new("add-pmem") .about("Add persistent memory device") .arg( - Arg::with_name("pmem_config") + Arg::new("pmem_config") .index(1) .help(vmm::config::PmemConfig::SYNTAX), ), ) .subcommand( - SubCommand::with_name("add-net") - .about("Add network device") - .arg( - Arg::with_name("net_config") - .index(1) - .help(vmm::config::NetConfig::SYNTAX), - ), + App::new("add-net").about("Add network device").arg( + Arg::new("net_config") + .index(1) + .help(vmm::config::NetConfig::SYNTAX), + ), ) .subcommand( - SubCommand::with_name("add-user-device") + App::new("add-user-device") .about("Add userspace device") .arg( - Arg::with_name("device_config") + Arg::new("device_config") .index(1) .help(vmm::config::UserDeviceConfig::SYNTAX), ), ) .subcommand( - SubCommand::with_name("add-vsock") - .about("Add vsock device") - .arg( - Arg::with_name("vsock_config") - .index(1) - .help(vmm::config::VsockConfig::SYNTAX), - ), + App::new("add-vsock").about("Add vsock device").arg( + Arg::new("vsock_config") + .index(1) + .help(vmm::config::VsockConfig::SYNTAX), + ), ) .subcommand( - SubCommand::with_name("remove-device") + App::new("remove-device") .about("Remove VFIO device") - .arg(Arg::with_name("id").index(1).help("")), + .arg(Arg::new("id").index(1).help("")), ) - .subcommand(SubCommand::with_name("info").about("Info on the VM")) - .subcommand(SubCommand::with_name("counters").about("Counters from the VM")) - .subcommand(SubCommand::with_name("pause").about("Pause the VM")) - .subcommand(SubCommand::with_name("reboot").about("Reboot the VM")) - .subcommand(SubCommand::with_name("power-button").about("Trigger a power button in the VM")) + .subcommand(App::new("info").about("Info on the VM")) + .subcommand(App::new("counters").about("Counters from the VM")) + .subcommand(App::new("pause").about("Pause the VM")) + .subcommand(App::new("reboot").about("Reboot the VM")) + .subcommand(App::new("power-button").about("Trigger a power button in the VM")) .subcommand( - SubCommand::with_name("resize") + App::new("resize") .about("Resize the VM") .arg( - Arg::with_name("cpus") + Arg::new("cpus") .long("cpus") .help("New vCPUs count") .takes_value(true) .number_of_values(1), ) .arg( - Arg::with_name("memory") + Arg::new("memory") .long("memory") .help("New memory size in bytes (supports K/M/G suffix)") .takes_value(true) .number_of_values(1), ) .arg( - Arg::with_name("balloon") + Arg::new("balloon") .long("balloon") .help("New balloon size in bytes (supports K/M/G suffix)") .takes_value(true) @@ -528,57 +520,53 @@ fn main() { ), ) .subcommand( - SubCommand::with_name("resize-zone") + App::new("resize-zone") .about("Resize a memory zone") .arg( - Arg::with_name("id") + Arg::new("id") .long("id") .help("Memory zone identifier") .takes_value(true) .number_of_values(1), ) .arg( - Arg::with_name("size") + Arg::new("size") .long("size") .help("New memory zone size in bytes (supports K/M/G suffix)") .takes_value(true) .number_of_values(1), ), ) - .subcommand(SubCommand::with_name("resume").about("Resume the VM")) - .subcommand(SubCommand::with_name("shutdown").about("Shutdown the VM")) + .subcommand(App::new("resume").about("Resume the VM")) + .subcommand(App::new("shutdown").about("Shutdown the VM")) .subcommand( - SubCommand::with_name("snapshot") - .about("Create a snapshot from VM") - .arg( - Arg::with_name("snapshot_config") - .index(1) - .help(""), - ), + App::new("snapshot").about("Create a snapshot from VM").arg( + Arg::new("snapshot_config") + .index(1) + .help(""), + ), ) .subcommand( - SubCommand::with_name("restore") - .about("Restore VM from a snapshot") - .arg( - Arg::with_name("restore_config") - .index(1) - .help(vmm::config::RestoreConfig::SYNTAX), - ), + App::new("restore").about("Restore VM from a snapshot").arg( + Arg::new("restore_config") + .index(1) + .help(vmm::config::RestoreConfig::SYNTAX), + ), ) .subcommand( - SubCommand::with_name("send-migration") + App::new("send-migration") .about("Initiate a VM migration") .arg( - Arg::with_name("send_migration_config") + Arg::new("send_migration_config") .index(1) .help(""), ), ) .subcommand( - SubCommand::with_name("receive-migration") + App::new("receive-migration") .about("Receive a VM migration") .arg( - Arg::with_name("receive_migration_config") + Arg::new("receive_migration_config") .index(1) .help(""), ), diff --git a/src/main.rs b/src/main.rs index c2a387825..011e8ee13 100644 --- a/src/main.rs +++ b/src/main.rs @@ -125,11 +125,11 @@ fn prepare_default_values() -> (String, String, String) { (default_vcpus, default_memory, default_rng) } -fn create_app<'a, 'b>( +fn create_app<'a>( default_vcpus: &'a str, default_memory: &'a str, default_rng: &'a str, -) -> App<'a, 'b> { +) -> App<'a> { #[cfg(target_arch = "x86_64")] let mut app: App; #[cfg(target_arch = "aarch64")] @@ -141,11 +141,11 @@ fn create_app<'a, 'b>( .version(env!("BUILT_VERSION")) .author(crate_authors!()) .about("Launch a cloud-hypervisor VMM.") - .group(ArgGroup::with_name("vm-config").multiple(true)) - .group(ArgGroup::with_name("vmm-config").multiple(true)) - .group(ArgGroup::with_name("logging").multiple(true)) + .group(ArgGroup::new("vm-config").multiple(true)) + .group(ArgGroup::new("vmm-config").multiple(true)) + .group(ArgGroup::new("logging").multiple(true)) .arg( - Arg::with_name("cpus") + Arg::new("cpus") .long("cpus") .help( "boot=,max=,\ @@ -157,7 +157,7 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("platform") + Arg::new("platform") .long("platform") .help( "num_pci_segments=", @@ -166,7 +166,7 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("memory") + Arg::new("memory") .long("memory") .help( "Memory parameters \ @@ -181,7 +181,7 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("memory-zone") + Arg::new("memory-zone") .long("memory-zone") .help( "User defined memory zone parameters \ @@ -198,7 +198,7 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("kernel") + Arg::new("kernel") .long("kernel") .help( "Path to loaded kernel. This may be a kernel or firmware that supports a PVH \ @@ -208,21 +208,21 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("initramfs") + Arg::new("initramfs") .long("initramfs") .help("Path to initramfs image") .takes_value(true) .group("vm-config"), ) .arg( - Arg::with_name("cmdline") + Arg::new("cmdline") .long("cmdline") .help("Kernel command line") .takes_value(true) .group("vm-config"), ) .arg( - Arg::with_name("disk") + Arg::new("disk") .long("disk") .help(config::DiskConfig::SYNTAX) .takes_value(true) @@ -230,7 +230,7 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("net") + Arg::new("net") .long("net") .help(config::NetConfig::SYNTAX) .takes_value(true) @@ -238,7 +238,7 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("rng") + Arg::new("rng") .long("rng") .help( "Random number generator parameters \"src=,iommu=on|off\"", @@ -247,14 +247,14 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("balloon") + Arg::new("balloon") .long("balloon") .help(config::BalloonConfig::SYNTAX) .takes_value(true) .group("vm-config"), ) .arg( - Arg::with_name("fs") + Arg::new("fs") .long("fs") .help(config::FsConfig::SYNTAX) .takes_value(true) @@ -262,7 +262,7 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("pmem") + Arg::new("pmem") .long("pmem") .help(config::PmemConfig::SYNTAX) .takes_value(true) @@ -270,14 +270,14 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("serial") + Arg::new("serial") .long("serial") .help("Control serial port: off|null|pty|tty|file=/path/to/a/file") .default_value("null") .group("vm-config"), ) .arg( - Arg::with_name("console") + Arg::new("console") .long("console") .help( "Control (virtio) console: \"off|null|pty|tty|file=/path/to/a/file,iommu=on|off\"", @@ -286,7 +286,7 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("device") + Arg::new("device") .long("device") .help(config::DeviceConfig::SYNTAX) .takes_value(true) @@ -294,7 +294,7 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("user-device") + Arg::new("user-device") .long("user-device") .help(config::UserDeviceConfig::SYNTAX) .takes_value(true) @@ -302,7 +302,7 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("vsock") + Arg::new("vsock") .long("vsock") .help(config::VsockConfig::SYNTAX) .takes_value(true) @@ -310,7 +310,7 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("numa") + Arg::new("numa") .long("numa") .help(config::NumaConfig::SYNTAX) .takes_value(true) @@ -318,21 +318,21 @@ fn create_app<'a, 'b>( .group("vm-config"), ) .arg( - Arg::with_name("watchdog") + Arg::new("watchdog") .long("watchdog") .help("Enable virtio-watchdog") .takes_value(false) .group("vm-config"), ) .arg( - Arg::with_name("v") - .short("v") - .multiple(true) + Arg::new("v") + .short('v') + .multiple_occurrences(true) .help("Sets the level of debugging output") .group("logging"), ) .arg( - Arg::with_name("log-file") + Arg::new("log-file") .long("log-file") .help("Log file. Standard error is used if not specified") .takes_value(true) @@ -340,7 +340,7 @@ fn create_app<'a, 'b>( .group("logging"), ) .arg( - Arg::with_name("api-socket") + Arg::new("api-socket") .long("api-socket") .help("HTTP API socket (UNIX domain socket): path= or fd=.") .takes_value(true) @@ -348,7 +348,7 @@ fn create_app<'a, 'b>( .group("vmm-config"), ) .arg( - Arg::with_name("event-monitor") + Arg::new("event-monitor") .long("event-monitor") .help("File to report events on: path= or fd=") .takes_value(true) @@ -356,7 +356,7 @@ fn create_app<'a, 'b>( .group("vmm-config"), ) .arg( - Arg::with_name("restore") + Arg::new("restore") .long("restore") .help(config::RestoreConfig::SYNTAX) .takes_value(true) @@ -364,7 +364,7 @@ fn create_app<'a, 'b>( .group("vmm-config"), ) .arg( - Arg::with_name("seccomp") + Arg::new("seccomp") .long("seccomp") .takes_value(true) .possible_values(&["true", "false", "log"]) @@ -374,7 +374,7 @@ fn create_app<'a, 'b>( #[cfg(target_arch = "x86_64")] { app = app.arg( - Arg::with_name("sgx-epc") + Arg::new("sgx-epc") .long("sgx-epc") .help(config::SgxEpcConfig::SYNTAX) .takes_value(true) @@ -386,7 +386,7 @@ fn create_app<'a, 'b>( #[cfg(feature = "tdx")] { app = app.arg( - Arg::with_name("tdx") + Arg::new("tdx") .long("tdx") .help("TDX Support: firmware=") .takes_value(true) diff --git a/vhost_user_block/Cargo.toml b/vhost_user_block/Cargo.toml index 92456a8b6..05f509884 100644 --- a/vhost_user_block/Cargo.toml +++ b/vhost_user_block/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] block_util = { path = "../block_util" } -clap = { version = "2.34.0", features = ["wrap_help"] } +clap = { version = "3.0.0", features = ["wrap_help"] } env_logger = "0.9.0" epoll = "4.3.1" libc = "0.2.112" diff --git a/vhost_user_block/src/main.rs b/vhost_user_block/src/main.rs index a9ca1f8a0..08ba9b48f 100644 --- a/vhost_user_block/src/main.rs +++ b/vhost_user_block/src/main.rs @@ -23,7 +23,7 @@ fn main() { .author(crate_authors!()) .about("Launch a vhost-user-blk backend.") .arg( - Arg::with_name("block-backend") + Arg::new("block-backend") .long("block-backend") .help(vhost_user_block::SYNTAX) .takes_value(true) diff --git a/vhost_user_net/Cargo.toml b/vhost_user_net/Cargo.toml index 2bfac9827..363d3e3fb 100644 --- a/vhost_user_net/Cargo.toml +++ b/vhost_user_net/Cargo.toml @@ -5,7 +5,7 @@ authors = ["The Cloud Hypervisor Authors"] edition = "2018" [dependencies] -clap = { version = "2.34.0", features = ["wrap_help"] } +clap = { version = "3.0.0", features = ["wrap_help"] } env_logger = "0.9.0" epoll = "4.3.1" libc = "0.2.112" diff --git a/vhost_user_net/src/main.rs b/vhost_user_net/src/main.rs index d5e0ed154..5a0b5c7b4 100644 --- a/vhost_user_net/src/main.rs +++ b/vhost_user_net/src/main.rs @@ -20,7 +20,7 @@ fn main() { .author(crate_authors!()) .about("Launch a vhost-user-net backend.") .arg( - Arg::with_name("net-backend") + Arg::new("net-backend") .long("net-backend") .help(vhost_user_net::SYNTAX) .takes_value(true) diff --git a/vmm/Cargo.toml b/vmm/Cargo.toml index d71f04e8c..5a04e7245 100644 --- a/vmm/Cargo.toml +++ b/vmm/Cargo.toml @@ -20,7 +20,7 @@ arc-swap = "1.5.0" arch = { path = "../arch" } bitflags = "1.3.2" block_util = { path = "../block_util" } -clap = "2.34.0" +clap = "3.0.0" devices = { path = "../devices" } epoll = "4.3.1" event_monitor = { path = "../event_monitor" }