mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-virtio: pmem: Expect an identifier upon device creation
This identifier is chosen from the DeviceManager so that it will manage all identifiers across the VM, which will ensure uniqueness. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
2e91b73881
commit
1592a9292f
@@ -1560,9 +1560,13 @@ impl DeviceManager {
|
||||
&mut self,
|
||||
pmem_cfg: &mut PmemConfig,
|
||||
) -> DeviceManagerResult<(VirtioDeviceArc, bool, Option<String>)> {
|
||||
if pmem_cfg.id.is_none() {
|
||||
pmem_cfg.id = Some(self.next_device_name(PMEM_DEVICE_NAME_PREFIX)?);
|
||||
}
|
||||
let id = if let Some(id) = &pmem_cfg.id {
|
||||
id.clone()
|
||||
} else {
|
||||
let id = self.next_device_name(PMEM_DEVICE_NAME_PREFIX)?;
|
||||
pmem_cfg.id = Some(id.clone());
|
||||
id
|
||||
};
|
||||
|
||||
let (custom_flags, set_len) = if pmem_cfg.file.is_dir() {
|
||||
if pmem_cfg.size.is_none() {
|
||||
@@ -1646,13 +1650,18 @@ impl DeviceManager {
|
||||
};
|
||||
|
||||
let virtio_pmem_device = Arc::new(Mutex::new(
|
||||
vm_virtio::Pmem::new(file, pmem_guest_addr, mapping, mmap_region, pmem_cfg.iommu)
|
||||
.map_err(DeviceManagerError::CreateVirtioPmem)?,
|
||||
vm_virtio::Pmem::new(
|
||||
id,
|
||||
file,
|
||||
pmem_guest_addr,
|
||||
mapping,
|
||||
mmap_region,
|
||||
pmem_cfg.iommu,
|
||||
)
|
||||
.map_err(DeviceManagerError::CreateVirtioPmem)?,
|
||||
));
|
||||
|
||||
let migratable = Arc::clone(&virtio_pmem_device) as Arc<Mutex<dyn Migratable>>;
|
||||
let id = migratable.lock().unwrap().id();
|
||||
self.migratable_devices.push((id, migratable));
|
||||
self.add_migratable_device(Arc::clone(&virtio_pmem_device) as Arc<Mutex<dyn Migratable>>);
|
||||
|
||||
Ok((
|
||||
Arc::clone(&virtio_pmem_device) as VirtioDeviceArc,
|
||||
|
||||
Reference in New Issue
Block a user