mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: DeviceConfig: Add fd field for an externally-opened vfio cdev
Add a new `fd: Option<i32>` field to DeviceConfig so a caller can supply a pre-opened vfio cdev FD (e.g. /dev/vfio/devices/vfioN) in addition to the existing sysfs path. The CLI `--device` option now accepts `fd=<n>`, parsed alongside the existing options. Signed-off-by: Bo Chen <bchen@crusoe.ai> Assisted-by: Claude:Opus-4.7
This commit is contained in:
+5
-1
@@ -2413,7 +2413,7 @@ impl DebugConsoleConfig {
|
||||
|
||||
impl DeviceConfig {
|
||||
pub const SYNTAX: &'static str = "Direct device assignment parameters \
|
||||
\"path=<device_path>,iommu=on|off,id=<device_id>,\
|
||||
\"path=<device_path>,fd=<vfio_cdev_fd>,iommu=on|off,id=<device_id>,\
|
||||
pci_segment=<segment_id>,pci_device_id=<pci_slot>,\
|
||||
x_nv_gpudirect_clique=<clique_id>,\
|
||||
x_exclude_mmap_bars=[<bar>...]\"";
|
||||
@@ -2422,6 +2422,7 @@ impl DeviceConfig {
|
||||
let mut parser = OptionParser::new();
|
||||
parser
|
||||
.add("path")
|
||||
.add("fd")
|
||||
.add_all(PciDeviceCommonConfig::OPTIONS_IOMMU)
|
||||
.add("x_nv_gpudirect_clique")
|
||||
.add("x_exclude_mmap_bars");
|
||||
@@ -2432,6 +2433,7 @@ impl DeviceConfig {
|
||||
.get("path")
|
||||
.map(PathBuf::from)
|
||||
.ok_or(Error::ParseDevicePathMissing)?;
|
||||
let fd = parser.convert::<i32>("fd").map_err(Error::ParseDevice)?;
|
||||
let x_nv_gpudirect_clique = parser
|
||||
.convert::<u8>("x_nv_gpudirect_clique")
|
||||
.map_err(Error::ParseDevice)?;
|
||||
@@ -2443,6 +2445,7 @@ impl DeviceConfig {
|
||||
Ok(DeviceConfig {
|
||||
pci_common,
|
||||
path: Some(path),
|
||||
fd,
|
||||
x_nv_gpudirect_clique,
|
||||
x_exclude_mmap_bars,
|
||||
})
|
||||
@@ -4722,6 +4725,7 @@ id=\"{id}\",pci_segment={pci_segment},queue_sizes={queue_sizes}"
|
||||
DeviceConfig {
|
||||
pci_common: PciDeviceCommonConfig::default(),
|
||||
path: Some(PathBuf::from("/path/to/device")),
|
||||
fd: None,
|
||||
x_nv_gpudirect_clique: None,
|
||||
x_exclude_mmap_bars: Vec::new(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user