mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-11-04 19:11:11 +00:00
device_manager: assert passthrough_device has the correct type
There is a lot of unsafe code in such a small function. Add an assert to help detect issues earlier. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
47b5581c50
commit
0e8769d76a
@ -2959,6 +2959,8 @@ impl DeviceManager {
|
||||
return vmm_sys_util::errno::errno_result().map_err(DeviceManagerError::DupFd);
|
||||
}
|
||||
|
||||
assert!(passthrough_device.as_any().is::<DeviceFd>());
|
||||
|
||||
// SAFETY the raw fd conversion here is safe because:
|
||||
// 1. When running on KVM or MSHV, passthrough_device wraps around DeviceFd.
|
||||
// 2. The conversion here extracts the raw fd and then turns the raw fd into a DeviceFd
|
||||
|
Loading…
Reference in New Issue
Block a user