vmm: DeviceConfig: Store path as Option<PathBuf>

Relax DeviceConfig::path from PathBuf to Option<PathBuf> in preparation
to accept an externally-opened vfio cdev FD. The parser and OpenAPI spec
still enforces that `path` is set, so callers see no behavior change.

Signed-off-by: Bo Chen <bchen@crusoe.ai>
Assisted-by: Claude:Opus-4.7
This commit is contained in:
Bo Chen
2026-04-28 03:48:43 +00:00
committed by Rob Bradford
parent 96ea24339d
commit bc5363823a
3 changed files with 25 additions and 14 deletions

View File

@@ -3976,9 +3976,13 @@ impl DeviceManager {
vfio_ops
};
let vfio_device =
VfioDevice::new(&device_cfg.path, Arc::clone(&vfio_ops) as Arc<dyn VfioOps>)
.map_err(DeviceManagerError::VfioCreate)?;
// The CLI parser and OpenAPI spec enforce that `path` is set
let device_path = device_cfg
.path
.as_deref()
.expect("DeviceConfig::parse enforces a path");
let vfio_device = VfioDevice::new(device_path, Arc::clone(&vfio_ops) as Arc<dyn VfioOps>)
.map_err(DeviceManagerError::VfioCreate)?;
if needs_dma_mapping {
// Register DMA mapping in IOMMU.
@@ -4063,7 +4067,7 @@ impl DeviceManager {
.iter()
.map(|bar| *bar as u8)
.collect(),
device_cfg.path.clone(),
device_path.to_path_buf(),
)
.map_err(DeviceManagerError::VfioPciCreate)?;