vmm: Support direct device assignment

With the VFIO crate, we can now support directly assigned PCI devices
into cloud-hypervisor guests.

We support assigning multiple host devices, through the --device command
line parameter. This parameter takes the host device sysfs path.

Fixes: #60

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz
2019-07-15 11:42:40 +02:00
parent b746dd7116
commit 4d16ca8ae7
5 changed files with 120 additions and 0 deletions

View File

@@ -100,6 +100,13 @@ fn main() {
.help("Control (virtio) console: off|tty|file=/path/to/a/file")
.default_value("tty"),
)
.arg(
Arg::with_name("device")
.long("device")
.help("Direct device assignment parameter")
.takes_value(true)
.min_values(1),
)
.get_matches();
// These .unwrap()s cannot fail as there is a default value defined
@@ -118,6 +125,7 @@ fn main() {
let console = cmd_arguments.value_of("console").unwrap();
let fs: Option<Vec<&str>> = cmd_arguments.values_of("fs").map(|x| x.collect());
let pmem: Option<Vec<&str>> = cmd_arguments.values_of("pmem").map(|x| x.collect());
let devices: Option<Vec<&str>> = cmd_arguments.values_of("device").map(|x| x.collect());
let vm_config = match config::VmConfig::parse(config::VmParams {
cpus,
@@ -131,6 +139,7 @@ fn main() {
pmem,
serial,
console,
devices,
}) {
Ok(config) => config,
Err(e) => {