From 618722cdcad20241ff4a38f287b8cfe0a333f07b Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Fri, 3 Jul 2020 10:54:36 +0200 Subject: [PATCH] hypervisor: cpu: Rename state getter and setter vcpu.{set_}cpu_state() is a stutter. Signed-off-by: Samuel Ortiz --- hypervisor/src/cpu.rs | 9 +++++---- hypervisor/src/kvm/mod.rs | 14 +++++++------- vmm/src/cpu.rs | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/hypervisor/src/cpu.rs b/hypervisor/src/cpu.rs index 9708b1ad2..37c37a8ae 100644 --- a/hypervisor/src/cpu.rs +++ b/hypervisor/src/cpu.rs @@ -286,12 +286,13 @@ pub trait Vcpu: Send + Sync { #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] fn get_one_reg(&self, reg_id: u64) -> Result; /// - /// Retrieve the current cpu states. This function is necessary to snapshot the VM + /// Retrieve the vCPU state. + /// This function is necessary to snapshot the VM /// - fn cpu_state(&self) -> Result; + fn state(&self) -> Result; /// - /// Setting the FPU state this. + /// Set the vCPU state. /// This function is required when restoring the VM /// - fn set_cpu_state(&self, state: &CpuState) -> Result<()>; + fn set_state(&self, state: &CpuState) -> Result<()>; } diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index 5f2274966..49c2a21a9 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -638,9 +638,9 @@ impl cpu::Vcpu for KvmVcpu { /// let vm = hv.create_vm().expect("new VM fd creation failed"); /// vm.enable_split_irq().unwrap(); /// let vcpu = vm.create_vcpu(0).unwrap(); - /// let state = vcpu.cpu_state().unwrap(); + /// let state = vcpu.state().unwrap(); /// ``` - fn cpu_state(&self) -> cpu::Result { + fn state(&self) -> cpu::Result { let mp_state = self.get_mp_state()?; let regs = self.get_regs()?; let sregs = self.get_sregs()?; @@ -665,7 +665,7 @@ impl cpu::Vcpu for KvmVcpu { }) } #[cfg(target_arch = "aarch64")] - fn cpu_state(&self) -> cpu::Result { + fn state(&self) -> cpu::Result { unimplemented!(); } #[cfg(target_arch = "x86_64")] @@ -705,10 +705,10 @@ impl cpu::Vcpu for KvmVcpu { /// let vm = hv.create_vm().expect("new VM fd creation failed"); /// vm.enable_split_irq().unwrap(); /// let vcpu = vm.create_vcpu(0).unwrap(); - /// let state = vcpu.cpu_state().unwrap(); - /// vcpu.set_cpu_state(&state).unwrap(); + /// let state = vcpu.state().unwrap(); + /// vcpu.set_state(&state).unwrap(); /// ``` - fn set_cpu_state(&self, state: &CpuState) -> cpu::Result<()> { + fn set_state(&self, state: &CpuState) -> cpu::Result<()> { self.set_mp_state(state.mp_state)?; self.set_regs(&state.regs)?; self.set_sregs(&state.sregs)?; @@ -723,7 +723,7 @@ impl cpu::Vcpu for KvmVcpu { } #[allow(unused_variables)] #[cfg(target_arch = "aarch64")] - fn set_cpu_state(&self, state: &CpuState) -> cpu::Result<()> { + fn set_state(&self, state: &CpuState) -> cpu::Result<()> { Ok(()) } } diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 62dc1fead..33d1676f5 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -403,7 +403,7 @@ const VCPU_SNAPSHOT_ID: &str = "vcpu"; impl Pausable for Vcpu { fn pause(&mut self) -> std::result::Result<(), MigratableError> { self.saved_state = - Some(self.fd.cpu_state().map_err(|e| { + Some(self.fd.state().map_err(|e| { MigratableError::Pause(anyhow!("Could not get vCPU state {:?}", e)) })?); @@ -412,7 +412,7 @@ impl Pausable for Vcpu { fn resume(&mut self) -> std::result::Result<(), MigratableError> { if let Some(vcpu_state) = &self.saved_state { - self.fd.set_cpu_state(vcpu_state).map_err(|e| { + self.fd.set_state(vcpu_state).map_err(|e| { MigratableError::Pause(anyhow!("Could not set the vCPU state {:?}", e)) })?; }