MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / validate_pci_device_id

Function validate_pci_device_id

vmm/src/config.rs:433–444  ·  view source on GitHub ↗

Check that the PCI device supplied is neither out of range nor does it use any reserved device ID.

(device_id: u8)

Source from the content-addressed store, hash-verified

431/// Check that the PCI device supplied is neither out of range nor does
432/// it use any reserved device ID.
433fn validate_pci_device_id(device_id: u8) -> ValidationResult<()> {
434 if device_id >= pci::NUM_DEVICE_IDS {
435 // Check the given ID is not out of range
436 return Err(ValidationError::InvalidPciDeviceId(device_id));
437 } else if device_id == pci::PCI_ROOT_DEVICE_ID {
438 // Check the ID isn't any reserved one. Currently, only the device ID
439 // for the root device is reserved.
440 return Err(ValidationError::ReservedPciDeviceId(device_id));
441 }
442
443 Ok(())
444}
445
446pub type Result<T> = result::Result<T, Error>;
447

Callers 1

validateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected