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

Method next_device_name

vmm/src/device_manager.rs:3736–3757  ·  view source on GitHub ↗
(&mut self, prefix: &str)

Source from the content-addressed store, hash-verified

3734 }
3735
3736 fn next_device_name(&mut self, prefix: &str) -> DeviceManagerResult<String> {
3737 let start_id = self.device_id_cnt;
3738 loop {
3739 // Generate the temporary name.
3740 let name = format!("{}{}", prefix, self.device_id_cnt);
3741 // Increment the counter.
3742 self.device_id_cnt += Wrapping(1);
3743 // Check if the name is already in use.
3744 if !self.boot_id_list.contains(&name)
3745 && !self.device_tree.lock().unwrap().contains_key(&name)
3746 {
3747 return Ok(name);
3748 }
3749
3750 if self.device_id_cnt == start_id {
3751 // We went through a full loop and there's nothing else we can
3752 // do.
3753 break;
3754 }
3755 }
3756 Err(DeviceManagerError::NoAvailableDeviceName)
3757 }
3758
3759 fn add_passthrough_device(
3760 &mut self,

Callers 9

make_virtio_fs_deviceMethod · 0.80
make_vdpa_deviceMethod · 0.80
add_vfio_deviceMethod · 0.80
add_vfio_user_deviceMethod · 0.80

Calls 2

containsMethod · 0.80
contains_keyMethod · 0.45

Tested by

no test coverage detected