hypervisor: allow downcasting to KVM / MSHV device fd

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu
2022-07-09 11:09:33 +00:00
committed by Rob Bradford
parent 28683b8471
commit ddad5f3510
3 changed files with 17 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ pub use mshv_bindings::*;
pub use mshv_ioctls::IoEventAddress;
use mshv_ioctls::{set_registers_64, Mshv, NoDatamatch, VcpuFd, VmFd};
use serde::{Deserialize, Serialize};
use std::any::Any;
use std::collections::HashMap;
use std::sync::{Arc, RwLock};
use vm::DataMatch;
@@ -687,6 +688,12 @@ impl device::Device for MshvDevice {
.get_device_attr(attr)
.map_err(|e| device::HypervisorDeviceError::GetDeviceAttribute(e.into()))
}
///
/// Cast to the underlying MSHV device fd
///
fn as_any(&self) -> &dyn Any {
self
}
}
impl AsRawFd for MshvDevice {