mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-18 10:35:23 +00:00
vfio_user: Add command line parsing for socket option
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
19e893fa53
commit
c8967fcc37
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1384,6 +1384,7 @@ dependencies = [
|
|||||||
name = "vfio_user"
|
name = "vfio_user"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"argh",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -20,5 +20,6 @@ vm-memory = { version = "0.10.0", features = ["backend-mmap", "backend-atomic"]
|
|||||||
vmm-sys-util = "0.11.0"
|
vmm-sys-util = "0.11.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
argh = "0.1.9"
|
||||||
env_logger = "0.10.0"
|
env_logger = "0.10.0"
|
||||||
pci = { path = "../pci" }
|
pci = { path = "../pci" }
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
|
use argh::FromArgs;
|
||||||
use log::info;
|
use log::info;
|
||||||
use pci::PciBarConfiguration;
|
use pci::PciBarConfiguration;
|
||||||
use std::{fs::File, mem::size_of, path::PathBuf};
|
use std::{fs::File, mem::size_of, path::PathBuf};
|
||||||
@ -24,9 +25,18 @@ impl pci::PciSubclass for PciVfioUserSubclass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(FromArgs)]
|
||||||
|
/// GPIO test device
|
||||||
|
struct Args {
|
||||||
|
/// path to socket
|
||||||
|
#[argh(option)]
|
||||||
|
socket_path: String,
|
||||||
|
}
|
||||||
|
|
||||||
struct TestBackend {
|
struct TestBackend {
|
||||||
configuration: pci::PciConfiguration,
|
configuration: pci::PciConfiguration,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestBackend {
|
impl TestBackend {
|
||||||
fn new() -> TestBackend {
|
fn new() -> TestBackend {
|
||||||
let subclass = PciVfioUserSubclass::VfioUserSubclass;
|
let subclass = PciVfioUserSubclass::VfioUserSubclass;
|
||||||
@ -174,12 +184,12 @@ fn create_irqs() -> Vec<IrqInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let a: Args = argh::from_env();
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
let regions = create_regions();
|
let regions = create_regions();
|
||||||
let irqs = create_irqs();
|
let irqs = create_irqs();
|
||||||
|
|
||||||
let path = PathBuf::from("/tmp/vfio-user-test.socket");
|
let path = PathBuf::from(a.socket_path);
|
||||||
let s = Server::new(&path, true, irqs, regions).unwrap();
|
let s = Server::new(&path, true, irqs, regions).unwrap();
|
||||||
let mut test_backend = TestBackend::new();
|
let mut test_backend = TestBackend::new();
|
||||||
s.run(&mut test_backend).unwrap();
|
s.run(&mut test_backend).unwrap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user