Linux: Add parameter to pass host pcie root port into guest
Add pcie-root-port parameter, it specify host pcie root port's sysfs, then
it will have a virtual pcie root port in guest, as guest and host have
the same pci address, so virtual pcie root port creation should be prior
to build_vm().
BUG=b:185084350
TEST=boot CrOS with --pcie-root-port=sysfs_path in ManaTEE and check virtual
RP's function in CrOS
Change-Id: Id357e0de057d5387f135213e89702f27163faaee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3423460
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
diff --git a/src/main.rs b/src/main.rs
index 0fb45d1..8b343d6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2332,6 +2332,24 @@
})?,
)
}
+ #[cfg(feature = "direct")]
+ "pcie-root-port" => {
+ let pcie_path = PathBuf::from(value.unwrap());
+ if !pcie_path.exists() {
+ return Err(argument::Error::InvalidValue {
+ value: value.unwrap().to_owned(),
+ expected: String::from("the pcie root port path does not exist"),
+ });
+ }
+ if !pcie_path.is_dir() {
+ return Err(argument::Error::InvalidValue {
+ value: value.unwrap().to_owned(),
+ expected: String::from("the pcie root port path should be directory"),
+ });
+ }
+
+ cfg.pcie_rp.push(pcie_path);
+ }
"help" => return Err(argument::Error::PrintHelp),
_ => unreachable!(),
}
@@ -2705,6 +2723,8 @@
rw - make the mapping writable
sync - open backing file with O_SYNC
align - whether to adjust addr and size to page boundaries implicitly"),
+ #[cfg(feature = "direct")]
+ Argument::value("pcie-root-port", "PATH", "Path to sysfs of host pcie root port"),
Argument::short_flag('h', "help", "Print help message.")];
let mut cfg = Config::default();