mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-22 07:51:16 +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"
|
name = "vhost_user_block"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"argh",
|
||||||
"block_util",
|
"block_util",
|
||||||
"clap",
|
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"epoll",
|
"epoll",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -5,8 +5,8 @@ authors = ["The Cloud Hypervisor Authors"]
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
argh = "0.1.9"
|
||||||
block_util = { path = "../block_util" }
|
block_util = { path = "../block_util" }
|
||||||
clap = { version = "4.0.32", features = ["wrap_help"] }
|
|
||||||
env_logger = "0.10.0"
|
env_logger = "0.10.0"
|
||||||
epoll = "4.3.1"
|
epoll = "4.3.1"
|
||||||
libc = "0.2.139"
|
libc = "0.2.139"
|
||||||
|
@ -70,11 +70,6 @@ enum Error {
|
|||||||
SocketParameterMissing,
|
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 {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "vhost_user_block_error: {self:?}")
|
write!(f, "vhost_user_block_error: {self:?}")
|
||||||
|
@ -10,25 +10,22 @@
|
|||||||
|
|
||||||
extern crate vhost_user_block;
|
extern crate vhost_user_block;
|
||||||
|
|
||||||
use clap::{Arg, Command};
|
use argh::FromArgs;
|
||||||
use vhost_user_block::start_block_backend;
|
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() {
|
fn main() {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
let cmd_arguments = Command::new("vhost-user-blk backend")
|
let toplevel: TopLevel = argh::from_env();
|
||||||
.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 backend_command = cmd_arguments.get_one::<String>("block-backend").unwrap();
|
start_block_backend(&toplevel.backend_command);
|
||||||
start_block_backend(backend_command);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user