ch-remote, main, vhost_user: Fix deprecated APIs for clap v3.1.0

Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
Bo Chen 2022-02-16 17:23:45 -08:00 committed by dependabot[bot]
parent 5fd49927f2
commit 0ee8ead53d
4 changed files with 43 additions and 39 deletions

View File

@ -9,7 +9,7 @@ extern crate clap;
use api_client::simple_api_command; use api_client::simple_api_command;
use api_client::simple_api_command_with_fds; use api_client::simple_api_command_with_fds;
use api_client::Error as ApiClientError; use api_client::Error as ApiClientError;
use clap::{App, AppSettings, Arg, ArgMatches}; use clap::{Arg, ArgMatches, Command};
use option_parser::{ByteSized, ByteSizedParseError}; use option_parser::{ByteSized, ByteSizedParseError};
use std::fmt; use std::fmt;
use std::os::unix::net::UnixStream; use std::os::unix::net::UnixStream;
@ -426,9 +426,9 @@ fn do_command(matches: &ArgMatches) -> Result<(), Error> {
} }
fn main() { fn main() {
let app = App::new("ch-remote") let app = Command::new("ch-remote")
.author(crate_authors!()) .author(crate_authors!())
.setting(AppSettings::SubcommandRequired) .subcommand_required(true)
.about("Remotely control a cloud-hypervisor VMM.") .about("Remotely control a cloud-hypervisor VMM.")
.arg( .arg(
Arg::new("api-socket") Arg::new("api-socket")
@ -439,21 +439,21 @@ fn main() {
.required(true), .required(true),
) )
.subcommand( .subcommand(
App::new("add-device").about("Add VFIO device").arg( Command::new("add-device").about("Add VFIO device").arg(
Arg::new("device_config") Arg::new("device_config")
.index(1) .index(1)
.help(vmm::config::DeviceConfig::SYNTAX), .help(vmm::config::DeviceConfig::SYNTAX),
), ),
) )
.subcommand( .subcommand(
App::new("add-disk").about("Add block device").arg( Command::new("add-disk").about("Add block device").arg(
Arg::new("disk_config") Arg::new("disk_config")
.index(1) .index(1)
.help(vmm::config::DiskConfig::SYNTAX), .help(vmm::config::DiskConfig::SYNTAX),
), ),
) )
.subcommand( .subcommand(
App::new("add-fs") Command::new("add-fs")
.about("Add virtio-fs backed fs device") .about("Add virtio-fs backed fs device")
.arg( .arg(
Arg::new("fs_config") Arg::new("fs_config")
@ -462,7 +462,7 @@ fn main() {
), ),
) )
.subcommand( .subcommand(
App::new("add-pmem") Command::new("add-pmem")
.about("Add persistent memory device") .about("Add persistent memory device")
.arg( .arg(
Arg::new("pmem_config") Arg::new("pmem_config")
@ -471,14 +471,14 @@ fn main() {
), ),
) )
.subcommand( .subcommand(
App::new("add-net").about("Add network device").arg( Command::new("add-net").about("Add network device").arg(
Arg::new("net_config") Arg::new("net_config")
.index(1) .index(1)
.help(vmm::config::NetConfig::SYNTAX), .help(vmm::config::NetConfig::SYNTAX),
), ),
) )
.subcommand( .subcommand(
App::new("add-user-device") Command::new("add-user-device")
.about("Add userspace device") .about("Add userspace device")
.arg( .arg(
Arg::new("device_config") Arg::new("device_config")
@ -487,24 +487,24 @@ fn main() {
), ),
) )
.subcommand( .subcommand(
App::new("add-vsock").about("Add vsock device").arg( Command::new("add-vsock").about("Add vsock device").arg(
Arg::new("vsock_config") Arg::new("vsock_config")
.index(1) .index(1)
.help(vmm::config::VsockConfig::SYNTAX), .help(vmm::config::VsockConfig::SYNTAX),
), ),
) )
.subcommand( .subcommand(
App::new("remove-device") Command::new("remove-device")
.about("Remove VFIO device") .about("Remove VFIO device")
.arg(Arg::new("id").index(1).help("<device_id>")), .arg(Arg::new("id").index(1).help("<device_id>")),
) )
.subcommand(App::new("info").about("Info on the VM")) .subcommand(Command::new("info").about("Info on the VM"))
.subcommand(App::new("counters").about("Counters from the VM")) .subcommand(Command::new("counters").about("Counters from the VM"))
.subcommand(App::new("pause").about("Pause the VM")) .subcommand(Command::new("pause").about("Pause the VM"))
.subcommand(App::new("reboot").about("Reboot the VM")) .subcommand(Command::new("reboot").about("Reboot the VM"))
.subcommand(App::new("power-button").about("Trigger a power button in the VM")) .subcommand(Command::new("power-button").about("Trigger a power button in the VM"))
.subcommand( .subcommand(
App::new("resize") Command::new("resize")
.about("Resize the VM") .about("Resize the VM")
.arg( .arg(
Arg::new("cpus") Arg::new("cpus")
@ -529,7 +529,7 @@ fn main() {
), ),
) )
.subcommand( .subcommand(
App::new("resize-zone") Command::new("resize-zone")
.about("Resize a memory zone") .about("Resize a memory zone")
.arg( .arg(
Arg::new("id") Arg::new("id")
@ -546,24 +546,28 @@ fn main() {
.number_of_values(1), .number_of_values(1),
), ),
) )
.subcommand(App::new("resume").about("Resume the VM")) .subcommand(Command::new("resume").about("Resume the VM"))
.subcommand(App::new("shutdown").about("Shutdown the VM")) .subcommand(Command::new("shutdown").about("Shutdown the VM"))
.subcommand( .subcommand(
App::new("snapshot").about("Create a snapshot from VM").arg( Command::new("snapshot")
.about("Create a snapshot from VM")
.arg(
Arg::new("snapshot_config") Arg::new("snapshot_config")
.index(1) .index(1)
.help("<destination_url>"), .help("<destination_url>"),
), ),
) )
.subcommand( .subcommand(
App::new("restore").about("Restore VM from a snapshot").arg( Command::new("restore")
.about("Restore VM from a snapshot")
.arg(
Arg::new("restore_config") Arg::new("restore_config")
.index(1) .index(1)
.help(vmm::config::RestoreConfig::SYNTAX), .help(vmm::config::RestoreConfig::SYNTAX),
), ),
) )
.subcommand( .subcommand(
App::new("send-migration") Command::new("send-migration")
.about("Initiate a VM migration") .about("Initiate a VM migration")
.arg( .arg(
Arg::new("send_migration_config") Arg::new("send_migration_config")
@ -577,7 +581,7 @@ fn main() {
), ),
) )
.subcommand( .subcommand(
App::new("receive-migration") Command::new("receive-migration")
.about("Receive a VM migration") .about("Receive a VM migration")
.arg( .arg(
Arg::new("receive_migration_config") Arg::new("receive_migration_config")

View File

@ -8,7 +8,7 @@ extern crate clap;
#[macro_use] #[macro_use]
extern crate event_monitor; extern crate event_monitor;
use clap::{App, Arg, ArgGroup, ArgMatches}; use clap::{Arg, ArgGroup, ArgMatches, Command};
use libc::EFD_NONBLOCK; use libc::EFD_NONBLOCK;
use log::LevelFilter; use log::LevelFilter;
use option_parser::OptionParser; use option_parser::OptionParser;
@ -129,8 +129,8 @@ fn create_app<'a>(
default_vcpus: &'a str, default_vcpus: &'a str,
default_memory: &'a str, default_memory: &'a str,
default_rng: &'a str, default_rng: &'a str,
) -> App<'a> { ) -> Command<'a> {
let app = App::new("cloud-hypervisor") let app = Command::new("cloud-hypervisor")
// 'BUILT_VERSION' is set by the build script 'build.rs' at // 'BUILT_VERSION' is set by the build script 'build.rs' at
// compile time // compile time
.version(env!("BUILT_VERSION")) .version(env!("BUILT_VERSION"))

View File

@ -12,13 +12,13 @@
extern crate clap; extern crate clap;
extern crate vhost_user_block; extern crate vhost_user_block;
use clap::{App, Arg}; use clap::{Arg, Command};
use vhost_user_block::start_block_backend; use vhost_user_block::start_block_backend;
fn main() { fn main() {
env_logger::init(); env_logger::init();
let cmd_arguments = App::new("vhost-user-blk backend") let cmd_arguments = Command::new("vhost-user-blk backend")
.version(crate_version!()) .version(crate_version!())
.author(crate_authors!()) .author(crate_authors!())
.about("Launch a vhost-user-blk backend.") .about("Launch a vhost-user-blk backend.")

View File

@ -9,13 +9,13 @@
#[macro_use(crate_version, crate_authors)] #[macro_use(crate_version, crate_authors)]
extern crate clap; extern crate clap;
use clap::{App, Arg}; use clap::{Arg, Command};
use vhost_user_net::start_net_backend; use vhost_user_net::start_net_backend;
fn main() { fn main() {
env_logger::init(); env_logger::init();
let cmd_arguments = App::new("vhost-user-net backend") let cmd_arguments = Command::new("vhost-user-net backend")
.version(crate_version!()) .version(crate_version!())
.author(crate_authors!()) .author(crate_authors!())
.about("Launch a vhost-user-net backend.") .about("Launch a vhost-user-net backend.")