From 3220292d4528467873bc5b04b28ee0b48173b627 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 8 May 2020 16:11:00 +0100 Subject: [PATCH] vhost_user_net: Consolidate the vhost-user-net backend syntax Rather than repeat syntax for the vhost-user-net 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_net.rs | 6 +----- src/main.rs | 6 +----- vhost_user_net/src/lib.rs | 4 ++++ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/bin/vhost_user_net.rs b/src/bin/vhost_user_net.rs index 520bb0fe8..7d26aeb1c 100644 --- a/src/bin/vhost_user_net.rs +++ b/src/bin/vhost_user_net.rs @@ -21,11 +21,7 @@ fn main() { .arg( Arg::with_name("net-backend") .long("net-backend") - .help( - "vhost-user-net backend parameters \ - \"ip=,mask=,sock=,\ - num_queues=,queue_size=,tap=\"", - ) + .help(vhost_user_net::SYNTAX) .takes_value(true) .min_values(1), ) diff --git a/src/main.rs b/src/main.rs index 4208ab927..d757b0274 100755 --- a/src/main.rs +++ b/src/main.rs @@ -235,11 +235,7 @@ fn create_app<'a, 'b>( .arg( Arg::with_name("net-backend") .long("net-backend") - .help( - "vhost-user-net backend parameters \ - \"ip=,mask=,sock=,\ - num_queues=,queue_size=,tap=\"", - ) + .help(vhost_user_net::SYNTAX) .takes_value(true) .conflicts_with_all(&["block-backend", "kernel"]) .min_values(1), diff --git a/vhost_user_net/src/lib.rs b/vhost_user_net/src/lib.rs index 1a152b91f..d2518e3a6 100644 --- a/vhost_user_net/src/lib.rs +++ b/vhost_user_net/src/lib.rs @@ -77,6 +77,10 @@ pub enum Error { OpenTap(vm_virtio::net_util::Error), } +pub const SYNTAX: &str = "vhost-user-net backend parameters \ +\"ip=,mask=,sock=,\ +num_queues=,queue_size=,tap=\""; + impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "vhost_user_net_error: {:?}", self)