vhost_user_block: add --version

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

View File

@ -3,6 +3,7 @@ name = "vhost_user_block"
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

@ -19,7 +19,11 @@ struct TopLevel {
#[argh(option, long = "block-backend")] #[argh(option, long = "block-backend")]
/// vhost-user-block backend parameters /// vhost-user-block backend parameters
/// path=<image_path>,socket=<socket_path>,num_queues=<number_of_queues>,queue_size=<size_of_each_queue>,readonly=true|false,direct=true|false,poll_queue=true|false /// path=<image_path>,socket=<socket_path>,num_queues=<number_of_queues>,queue_size=<size_of_each_queue>,readonly=true|false,direct=true|false,poll_queue=true|false
backend_command: String, backend_command: Option<String>,
#[argh(switch, short = 'V', long = "version")]
/// print version information
version: bool,
} }
fn main() { fn main() {
@ -27,5 +31,15 @@ fn main() {
let toplevel: TopLevel = argh::from_env(); let toplevel: TopLevel = argh::from_env();
start_block_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 --block-backend");
std::process::exit(1)
}
start_block_backend(&toplevel.backend_command.unwrap());
} }