2019-10-23 16:36:01 +02:00
|
|
|
// Copyright 2019 Red Hat, Inc. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Portions Copyright 2019 Intel Corporation. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Portions Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Portions Copyright 2017 The Chromium OS Authors. All rights reserved.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: (Apache-2.0 AND BSD-3-Clause)
|
|
|
|
|
2020-01-20 16:10:21 +00:00
|
|
|
extern crate vhost_user_block;
|
2019-10-23 16:36:01 +02:00
|
|
|
|
2023-01-12 15:53:51 +00:00
|
|
|
use argh::FromArgs;
|
2020-01-21 15:16:38 +00:00
|
|
|
use vhost_user_block::start_block_backend;
|
2019-10-23 16:36:01 +02:00
|
|
|
|
2023-01-12 15:53:51 +00:00
|
|
|
#[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
|
2023-01-13 00:56:20 +00:00
|
|
|
backend_command: Option<String>,
|
|
|
|
|
|
|
|
#[argh(switch, short = 'V', long = "version")]
|
|
|
|
/// print version information
|
|
|
|
version: bool,
|
2023-01-12 15:53:51 +00:00
|
|
|
}
|
|
|
|
|
2019-10-23 16:36:01 +02:00
|
|
|
fn main() {
|
2021-08-04 19:35:56 +00:00
|
|
|
env_logger::init();
|
|
|
|
|
2023-01-12 15:53:51 +00:00
|
|
|
let toplevel: TopLevel = argh::from_env();
|
2019-10-23 16:36:01 +02:00
|
|
|
|
2023-01-13 00:56:20 +00:00
|
|
|
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());
|
2019-10-23 16:36:01 +02:00
|
|
|
}
|