mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Do the downcast of GicDevice in a safer way for AArch64
Downcasting of GicDevice trait might fail. Therefore we try to downcast the trait first and only if the downcasting succeeded we can then use the object to call methods. Otherwise, do nothing and log the failure. Signed-off-by: Henry Wang <Henry.Wang@arm.com>
This commit is contained in:
@@ -4147,14 +4147,19 @@ impl Pausable for DeviceManager {
|
||||
.get_gic_device()
|
||||
.unwrap(),
|
||||
);
|
||||
gic_device
|
||||
if let Some(gicv3_its) = gic_device
|
||||
.lock()
|
||||
.unwrap()
|
||||
.as_any_concrete_mut()
|
||||
.downcast_mut::<KvmGicV3Its>()
|
||||
.unwrap()
|
||||
.pause()?;
|
||||
}
|
||||
{
|
||||
gicv3_its.pause()?;
|
||||
} else {
|
||||
return Err(MigratableError::Pause(anyhow!(
|
||||
"GicDevice downcast to KvmGicV3Its failed when pausing device manager!"
|
||||
)));
|
||||
};
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user