mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: cleanup &Arc<dyn T> -> &dyn T
Consuming `&Arc<T>` as argument is almost always an antipattern as it hides whether the callee is going to take over (shared) ownership (by .clone()) or not. Instead, it is better to consume `&dyn T` or `Arc<dyn T>` to be more explicit. This commit cleans up the code. The change is very mechanic and was very easy to implement across the code base. Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de> On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
committed by
Rob Bradford
parent
e295719967
commit
7536a95424
@@ -40,7 +40,7 @@ impl InterruptRoute {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn enable(&self, vm: &Arc<dyn hypervisor::Vm>) -> Result<()> {
|
||||
pub fn enable(&self, vm: &dyn hypervisor::Vm) -> Result<()> {
|
||||
if !self.registered.load(Ordering::Acquire) {
|
||||
vm.register_irqfd(&self.irq_fd, self.gsi)
|
||||
.map_err(|e| io::Error::other(format!("Failed registering irq_fd: {e}")))?;
|
||||
@@ -52,7 +52,7 @@ impl InterruptRoute {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn disable(&self, vm: &Arc<dyn hypervisor::Vm>) -> Result<()> {
|
||||
pub fn disable(&self, vm: &dyn hypervisor::Vm) -> Result<()> {
|
||||
if self.registered.load(Ordering::Acquire) {
|
||||
vm.unregister_irqfd(&self.irq_fd, self.gsi)
|
||||
.map_err(|e| io::Error::other(format!("Failed unregistering irq_fd: {e}")))?;
|
||||
@@ -122,7 +122,7 @@ impl MsiInterruptGroup {
|
||||
impl InterruptSourceGroup for MsiInterruptGroup {
|
||||
fn enable(&self) -> Result<()> {
|
||||
for (_, route) in self.irq_routes.iter() {
|
||||
route.enable(&self.vm)?;
|
||||
route.enable(self.vm.as_ref())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -130,7 +130,7 @@ impl InterruptSourceGroup for MsiInterruptGroup {
|
||||
|
||||
fn disable(&self) -> Result<()> {
|
||||
for (_, route) in self.irq_routes.iter() {
|
||||
route.disable(&self.vm)?;
|
||||
route.disable(self.vm.as_ref())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -172,7 +172,7 @@ impl InterruptSourceGroup for MsiInterruptGroup {
|
||||
// So it's required to call disable() (which deassign KVM_IRQFD) before
|
||||
// set_gsi_routes() to avoid kernel panic (see #3827)
|
||||
if masked {
|
||||
route.disable(&self.vm)?;
|
||||
route.disable(self.vm.as_ref())?;
|
||||
}
|
||||
|
||||
let mut routes = self.gsi_msi_routes.lock().unwrap();
|
||||
@@ -185,7 +185,7 @@ impl InterruptSourceGroup for MsiInterruptGroup {
|
||||
// panic on kernel which not have commit a80ced6ea514
|
||||
// (KVM: SVM: fix panic on out-of-bounds guest IRQ).
|
||||
if !masked {
|
||||
route.enable(&self.vm)?;
|
||||
route.enable(self.vm.as_ref())?;
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
|
||||
Reference in New Issue
Block a user