mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-21 19:02:30 +00:00
vmm: Device name verification based on DeviceTree
Instead of relying on a PCI specific device list, we use the DeviceTree as a reference to determine if a device name is already in use or not. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
13724dbd22
commit
62aaccee28
@ -2741,7 +2741,7 @@ impl DeviceManager {
|
||||
// Increment the counter.
|
||||
self.device_id_cnt += Wrapping(1);
|
||||
// Check if the name is already in use.
|
||||
if !self.pci_id_list.contains_key(&name) {
|
||||
if !self.device_tree.lock().unwrap().contains_key(&name) {
|
||||
return Ok(name);
|
||||
}
|
||||
|
||||
@ -2864,7 +2864,7 @@ impl DeviceManager {
|
||||
.map_err(DeviceManagerError::VfioPciCreate)?;
|
||||
|
||||
let vfio_name = if let Some(id) = &device_cfg.id {
|
||||
if self.pci_id_list.contains_key(id) {
|
||||
if self.device_tree.lock().unwrap().contains_key(id) {
|
||||
return Err(DeviceManagerError::DeviceIdAlreadyInUse);
|
||||
}
|
||||
|
||||
@ -2955,9 +2955,6 @@ impl DeviceManager {
|
||||
)
|
||||
.map_err(DeviceManagerError::AddPciDevice)?;
|
||||
|
||||
if self.pci_id_list.contains_key(&device_id) {
|
||||
return Err(DeviceManagerError::DeviceIdAlreadyInUse);
|
||||
}
|
||||
self.pci_id_list.insert(device_id, bdf);
|
||||
Ok(bars)
|
||||
}
|
||||
|
@ -51,6 +51,9 @@ impl DeviceTree {
|
||||
pub fn new() -> Self {
|
||||
DeviceTree(HashMap::new())
|
||||
}
|
||||
pub fn contains_key(&self, k: &str) -> bool {
|
||||
self.0.contains_key(k)
|
||||
}
|
||||
pub fn get(&self, k: &str) -> Option<&DeviceNode> {
|
||||
self.0.get(k)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user