aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 9690eaa..d31d33e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -126,7 +126,7 @@ impl KvmRun {
libc::mmap(
std::ptr::null_mut(),
len,
- libc::PROT_READ,
+ libc::PROT_READ | libc::PROT_WRITE,
libc::MAP_SHARED,
vcpu.as_raw_fd(),
0,
@@ -153,6 +153,12 @@ impl ops::Drop for KvmRun {
impl AsRef<kvm_sys::kvm_run> for KvmRun {
fn as_ref(&self) -> &kvm_sys::kvm_run {
- unsafe { &(*self.ptr) }
+ unsafe { & *(self.ptr as *const kvm_sys::kvm_run) }
+ }
+}
+
+impl AsMut<kvm_sys::kvm_run> for KvmRun {
+ fn as_mut(&mut self) -> &mut kvm_sys::kvm_run {
+ unsafe { &mut *(self.ptr as *mut kvm_sys::kvm_run) }
}
}