vhost_user_net: add --version

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2023-01-13 00:57:20 +00:00 committed by Rob Bradford
parent b0a2ce0598
commit b8172408f8
2 changed files with 17 additions and 2 deletions

View File

@ -3,6 +3,7 @@ name = "vhost_user_net"
version = "0.1.0" version = "0.1.0"
authors = ["The Cloud Hypervisor Authors"] authors = ["The Cloud Hypervisor Authors"]
edition = "2021" edition = "2021"
build = "../build.rs"
[dependencies] [dependencies]
argh = "0.1.9" argh = "0.1.9"

View File

@ -15,7 +15,11 @@ struct TopLevel {
#[argh(option, long = "net-backend")] #[argh(option, long = "net-backend")]
/// vhost-user-net backend parameters /// 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> /// 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: String, backend_command: Option<String>,
#[argh(switch, short = 'V', long = "version")]
/// print version information
version: bool,
} }
fn main() { fn main() {
@ -23,5 +27,15 @@ fn main() {
let toplevel: TopLevel = argh::from_env(); let toplevel: TopLevel = argh::from_env();
start_net_backend(&toplevel.backend_command); if toplevel.version {
println!("{} {}", env!("CARGO_BIN_NAME"), env!("BUILT_VERSION"));
return;
}
if toplevel.backend_command.is_none() {
println!("Please specify --net-backend");
std::process::exit(1)
}
start_net_backend(&toplevel.backend_command.unwrap());
} }