cleanup: refactor &Arc<T> to &T or Arc<T>#7667
Open
daschinmoy21 wants to merge 2 commits intocloud-hypervisor:mainfrom
Open
cleanup: refactor &Arc<T> to &T or Arc<T>#7667daschinmoy21 wants to merge 2 commits intocloud-hypervisor:mainfrom
daschinmoy21 wants to merge 2 commits intocloud-hypervisor:mainfrom
Conversation
Refactor various functions to take &T or Arc<T> instead of &Arc<T> to remove double indirection. Specifically updated PciSegment::new and related methods to consume Arc<AddressManager>. Updated vmm/src/device_manager.rs to match the new signatures. Fixes cloud-hypervisor#7444 Signed-off-by: daschinmoy21 <daschinmoyy21@gmail.com>
phip1611
requested changes
Feb 5, 2026
Member
phip1611
left a comment
There was a problem hiding this comment.
thanks! This cleans up the code IMHO a lot! I think we should also get rid of &Mutex and lock on the caller side (where the call is cheap and we do not block other code for too long)
| id: u16, | ||
| numa_node: u32, | ||
| address_manager: &Arc<AddressManager>, | ||
| address_manager: Arc<AddressManager>, |
vmm/src/vm.rs
Outdated
| payload: &PayloadConfig, | ||
| #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] device_manager: &Arc< | ||
| Mutex<DeviceManager>, | ||
| #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] device_manager: &Mutex< |
Member
There was a problem hiding this comment.
|
|
||
| #[cfg(feature = "fw_cfg")] | ||
| pub fn fw_cfg(&self) -> Option<&Arc<Mutex<FwCfg>>> { | ||
| pub fn fw_cfg(&self) -> Option<&Mutex<FwCfg>> { |
Member
There was a problem hiding this comment.
vmm/src/acpi.rs
Outdated
| device_manager: &Arc<Mutex<DeviceManager>>, | ||
| cpu_manager: &Arc<Mutex<CpuManager>>, | ||
| memory_manager: &Arc<Mutex<MemoryManager>>, | ||
| device_manager: &Mutex<DeviceManager>, |
Member
There was a problem hiding this comment.
vmm/src/acpi.rs
Outdated
| device_manager: &Arc<Mutex<DeviceManager>>, | ||
| cpu_manager: &Arc<Mutex<CpuManager>>, | ||
| memory_manager: &Arc<Mutex<MemoryManager>>, | ||
| device_manager: &Mutex<DeviceManager>, |
Member
There was a problem hiding this comment.
| fn allocate_bars( | ||
| &mut self, | ||
| _allocator: &Arc<Mutex<SystemAllocator>>, | ||
| _allocator: &Mutex<SystemAllocator>, |
Member
There was a problem hiding this comment.
| fn allocate_bars( | ||
| &mut self, | ||
| allocator: &Arc<Mutex<SystemAllocator>>, | ||
| allocator: &Mutex<SystemAllocator>, |
Member
There was a problem hiding this comment.
| fn allocate_bars( | ||
| &mut self, | ||
| _allocator: &Arc<Mutex<SystemAllocator>>, | ||
| _allocator: &Mutex<SystemAllocator>, |
Member
There was a problem hiding this comment.
| fn allocate_bars( | ||
| &mut self, | ||
| _allocator: &Arc<Mutex<SystemAllocator>>, | ||
| _allocator: &Mutex<SystemAllocator>, |
Member
There was a problem hiding this comment.
Refactor ACPI table creation functions to take &DeviceManager instead of &Mutex<DeviceManager>, moving the locking responsibility to the caller. This ensures consistency across tables and simplifies the API. - Update create_acpi_tables* signatures and internal logic. - Move DeviceManager locking to Vm call sites. - Update generate_cmdline and populate_fw_cfg to take &DeviceManager. - Update get_interrupt_controller to take &self. - Fix fw_cfg helper return type using as_deref().
Author
|
Updated the changes.ACPI table creation functions now take &DeviceManager instead |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactored various functions to take &T or Arc instead of &Arc to remove double indirection
Updated PciSegment::new and related methods to consume Arc
Updated vmm/ src/device_manager.rs to match the new signatures
Fixes #7444