Skip to content

Commit

Permalink
mshv-ioctls: Add get/set APIs for synthetic event flags
Browse files Browse the repository at this point in the history
Signed-off-by: Muminul Islam <muislam@microsoft.com>
  • Loading branch information
russell-islam committed Mar 27, 2024
1 parent e591704 commit ffed391
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions mshv-ioctls/src/ioctls/vcpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,31 @@ impl VcpuFd {
};
self.set_vp_state_ioctl(&vp_state)
}

/// Returns the synthetic event flags
pub fn get_synic_event_flags_page(&self) -> Result<SynicEventFlagsPage> {
let buffer = Buffer::new(HV_PAGE_SIZE, HV_PAGE_SIZE)?;
let mut vp_state = mshv_get_set_vp_state {
buf_ptr: buffer.buf as u64,
buf_sz: buffer.size() as u32,
type_: MSHV_VP_STATE_SIMP as u8,
..Default::default()
};
self.get_vp_state_ioctl(&mut vp_state)?;
SynicEventFlagsPage::try_from(buffer)
}

/// Set the synthetic event flags
pub fn set_synic_event_flags_page(&self, data: &SynicEventFlagsPage) -> Result<()> {
let buffer = Buffer::try_from(data)?;
let vp_state = mshv_get_set_vp_state {
type_: MSHV_VP_STATE_SIMP as u8,
buf_sz: buffer.size() as u32,
buf_ptr: buffer.buf as u64,
..Default::default()
};
self.set_vp_state_ioctl(&vp_state)
}
}

#[allow(dead_code)]
Expand Down

0 comments on commit ffed391

Please sign in to comment.