mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-11 23:27:40 +00:00
vhost_user_blk: switch to argh
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
111225a2a5
commit
54e9ed9932
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1417,8 +1417,8 @@ dependencies = [
|
||||
name = "vhost_user_block"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"argh",
|
||||
"block_util",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"epoll",
|
||||
"libc",
|
||||
|
@ -5,8 +5,8 @@ authors = ["The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
argh = "0.1.9"
|
||||
block_util = { path = "../block_util" }
|
||||
clap = { version = "4.0.32", features = ["wrap_help"] }
|
||||
env_logger = "0.10.0"
|
||||
epoll = "4.3.1"
|
||||
libc = "0.2.139"
|
||||
|
@ -70,11 +70,6 @@ enum Error {
|
||||
SocketParameterMissing,
|
||||
}
|
||||
|
||||
pub const SYNTAX: &str = "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\"";
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "vhost_user_block_error: {self:?}")
|
||||
|
@ -10,25 +10,22 @@
|
||||
|
||||
extern crate vhost_user_block;
|
||||
|
||||
use clap::{Arg, Command};
|
||||
use argh::FromArgs;
|
||||
use vhost_user_block::start_block_backend;
|
||||
|
||||
#[derive(FromArgs)]
|
||||
/// Launch a vhost-user-blk backend.
|
||||
struct TopLevel {
|
||||
#[argh(option, long = "block-backend")]
|
||||
/// 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
|
||||
backend_command: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
|
||||
let cmd_arguments = Command::new("vhost-user-blk backend")
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.author(env!("CARGO_PKG_AUTHORS"))
|
||||
.about("Launch a vhost-user-blk backend.")
|
||||
.arg(
|
||||
Arg::new("block-backend")
|
||||
.long("block-backend")
|
||||
.help(vhost_user_block::SYNTAX)
|
||||
.num_args(1)
|
||||
.required(true),
|
||||
)
|
||||
.get_matches();
|
||||
let toplevel: TopLevel = argh::from_env();
|
||||
|
||||
let backend_command = cmd_arguments.get_one::<String>("block-backend").unwrap();
|
||||
start_block_backend(backend_command);
|
||||
start_block_backend(&toplevel.backend_command);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user