From f3f398eb444209af88928de680285276c9ed86a0 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 8 May 2020 16:11:00 +0100 Subject: [PATCH] vhost_user_block: Consolidate the vhost-user-block backend syntax Rather than repeat syntax for the vhost-user-block backend in multiple places store it in one place and reference it from the required places. Signed-off-by: Rob Bradford --- src/bin/vhost_user_blk.rs | 6 +----- src/main.rs | 6 +----- vhost_user_block/src/lib.rs | 4 ++++ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/bin/vhost_user_blk.rs b/src/bin/vhost_user_blk.rs index a2b7b2224..c1e589770 100644 --- a/src/bin/vhost_user_blk.rs +++ b/src/bin/vhost_user_blk.rs @@ -23,11 +23,7 @@ fn main() { .arg( Arg::with_name("block-backend") .long("block-backend") - .help( - "vhost-user-block backend parameters \ - \"path=,socket=,num_queues=,\ - readonly=true|false,direct=true|false,poll_queue=true|false\"", - ) + .help(vhost_user_block::SYNTAX) .takes_value(true) .min_values(1), ) diff --git a/src/main.rs b/src/main.rs index d757b0274..4b41903ce 100755 --- a/src/main.rs +++ b/src/main.rs @@ -243,11 +243,7 @@ fn create_app<'a, 'b>( .arg( Arg::with_name("block-backend") .long("block-backend") - .help( - "vhost-user-block backend parameters \ - \"path=,socket=,num_queues=,\ - readonly=true|false,direct=true|false,poll_queue=true|false\"", - ) + .help(vhost_user_block::SYNTAX) .takes_value(true) .conflicts_with_all(&["net-backend", "kernel"]) .min_values(1), diff --git a/vhost_user_block/src/lib.rs b/vhost_user_block/src/lib.rs index 35dee2cfa..f60638cf3 100644 --- a/vhost_user_block/src/lib.rs +++ b/vhost_user_block/src/lib.rs @@ -77,6 +77,10 @@ enum Error { HandleEventUnknownEvent, } +pub const SYNTAX: &str = "vhost-user-block backend parameters \ + \"path=,socket=,num_queues=,\ + 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)