mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +00:00
vhost_user_net: switch to clap
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@intel.com>
This commit is contained in:
parent
d1f337aef1
commit
627a1456a7
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -434,7 +434,9 @@ dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"once_cell",
|
||||
"strsim",
|
||||
"terminal_size",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2033,6 +2035,16 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "terminal_size"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237"
|
||||
dependencies = [
|
||||
"rustix 0.37.25",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "test_infra"
|
||||
version = "0.1.0"
|
||||
@ -2316,7 +2328,7 @@ dependencies = [
|
||||
name = "vhost_user_net"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"argh",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"epoll",
|
||||
"libc",
|
||||
|
@ -6,7 +6,7 @@ edition = "2021"
|
||||
build = "../build.rs"
|
||||
|
||||
[dependencies]
|
||||
argh = "0.1.9"
|
||||
clap = { version = "4.3.11", features = ["wrap_help","cargo"] }
|
||||
env_logger = "0.10.0"
|
||||
epoll = "4.3.3"
|
||||
libc = "0.2.147"
|
||||
|
@ -6,36 +6,25 @@
|
||||
//
|
||||
// SPDX-License-Identifier: (Apache-2.0 AND BSD-3-Clause)
|
||||
|
||||
use argh::FromArgs;
|
||||
use clap::{Arg, Command};
|
||||
use vhost_user_net::start_net_backend;
|
||||
|
||||
#[derive(FromArgs)]
|
||||
/// Launch a vhost-user-net backend.
|
||||
struct TopLevel {
|
||||
#[argh(option, long = "net-backend")]
|
||||
/// vhost-user-net backend parameters
|
||||
/// ip=<ip_addr>,mask=<net_mask>,socket=<socket_path>,client=on|off,num_queues=<number_of_queues>,queue_size=<size_of_each_queue>,tap=<if_name>
|
||||
backend_command: Option<String>,
|
||||
|
||||
#[argh(switch, short = 'V', long = "version")]
|
||||
/// print version information
|
||||
version: bool,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
|
||||
let toplevel: TopLevel = argh::from_env();
|
||||
let cmd_arguments = Command::new("vhost-user-net backend")
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.author(env!("CARGO_PKG_AUTHORS"))
|
||||
.about("Launch a vhost-user-net backend.")
|
||||
.arg(
|
||||
Arg::new("net-backend")
|
||||
.long("net-backend")
|
||||
.help(vhost_user_net::SYNTAX)
|
||||
.num_args(1)
|
||||
.required(true),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
if toplevel.version {
|
||||
println!("{} {}", env!("CARGO_BIN_NAME"), env!("BUILD_VERSION"));
|
||||
return;
|
||||
}
|
||||
|
||||
if toplevel.backend_command.is_none() {
|
||||
println!("Please specify --net-backend");
|
||||
std::process::exit(1)
|
||||
}
|
||||
|
||||
start_net_backend(&toplevel.backend_command.unwrap());
|
||||
let backend_command = cmd_arguments.get_one::<String>("net-backend").unwrap();
|
||||
start_net_backend(backend_command);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user