summary refs log tree commit diff
path: root/hypervisor/src/kvm/mod.rs
diff options
context:
space:
mode:
authorSteven Richman <srichman@google.com>2020-05-13 17:22:33 -0700
committerCommit Bot <commit-bot@chromium.org>2020-06-03 12:32:41 +0000
commit1d6967437edc98716e545b82a28c788febfbe79a (patch)
tree45a1fd559229912614a1082295171bde0788bfa2 /hypervisor/src/kvm/mod.rs
parentee215426f4e61474aea546b5c0b6c1f1040d5344 (diff)
downloadcrosvm-1d6967437edc98716e545b82a28c788febfbe79a.tar
crosvm-1d6967437edc98716e545b82a28c788febfbe79a.tar.gz
crosvm-1d6967437edc98716e545b82a28c788febfbe79a.tar.bz2
crosvm-1d6967437edc98716e545b82a28c788febfbe79a.tar.lz
crosvm-1d6967437edc98716e545b82a28c788febfbe79a.tar.xz
crosvm-1d6967437edc98716e545b82a28c788febfbe79a.tar.zst
crosvm-1d6967437edc98716e545b82a28c788febfbe79a.zip
hypervisor: add get/set_pvclock
The clock functions on the Vm trait are for any arch, to support
hypervisors that might have ARM pv clocks.  The KVM implementation (x86
only) is mostly the same as before, but uses a hypervisor-agnostic
ClockState struct instead of the KVM struct.

BUG=chromium:1077058
TEST=cargo test -p hypervisor

Change-Id: I0e77ae997d6a30851d28aeb5f73c9ef8ebc464a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2202742
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
Diffstat (limited to 'hypervisor/src/kvm/mod.rs')
-rw-r--r--hypervisor/src/kvm/mod.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs
index 0550792..5fdf124 100644
--- a/hypervisor/src/kvm/mod.rs
+++ b/hypervisor/src/kvm/mod.rs
@@ -24,7 +24,9 @@ use sys_util::{
     GuestMemory, RawDescriptor, Result, SafeDescriptor,
 };
 
-use crate::{Hypervisor, HypervisorCap, MappedRegion, RunnableVcpu, Vcpu, VcpuExit, Vm};
+use crate::{
+    ClockState, Hypervisor, HypervisorCap, MappedRegion, RunnableVcpu, Vcpu, VcpuExit, Vm,
+};
 
 // Wrapper around KVM_SET_USER_MEMORY_REGION ioctl, which creates, modifies, or deletes a mapping
 // from guest physical to host user pages.
@@ -184,6 +186,14 @@ impl Vm for KvmVm {
     fn get_memory(&self) -> &GuestMemory {
         &self.guest_mem
     }
+
+    fn get_pvclock(&self) -> Result<ClockState> {
+        self.get_pvclock_arch()
+    }
+
+    fn set_pvclock(&self, state: &ClockState) -> Result<()> {
+        self.set_pvclock_arch(state)
+    }
 }
 
 impl AsRawDescriptor for KvmVm {