Skip to content

Commit 02a4a55

Browse files
zulinx86kalyazin
authored andcommitted
refactor(vmm): use upper camel case for error type
Update error items to use upper camel case for consistency. Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent 47dae46 commit 02a4a55

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/vmm/src/arch/x86_64/msr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ pub fn create_boot_msr_entries() -> Vec<kvm_msr_entry> {
275275

276276
/// Error type for [`set_msrs`].
277277
#[derive(Debug, thiserror::Error, Eq, PartialEq)]
278-
pub enum SetMSRsError {
278+
pub enum SetMsrsError {
279279
/// Failed to create [`vmm_sys_util::fam::FamStructWrapper`] for MSRs.
280280
#[error("Could not create `vmm_sys_util::fam::FamStructWrapper` for MSRs")]
281281
Create(utils::fam::Error),
@@ -302,15 +302,15 @@ pub enum SetMSRsError {
302302
pub fn set_msrs(
303303
vcpu: &VcpuFd,
304304
msr_entries: &[kvm_msr_entry],
305-
) -> std::result::Result<(), SetMSRsError> {
306-
let msrs = Msrs::from_entries(msr_entries).map_err(SetMSRsError::Create)?;
305+
) -> std::result::Result<(), SetMsrsError> {
306+
let msrs = Msrs::from_entries(msr_entries).map_err(SetMsrsError::Create)?;
307307
vcpu.set_msrs(&msrs)
308-
.map_err(SetMSRsError::Set)
308+
.map_err(SetMsrsError::Set)
309309
.and_then(|msrs_written| {
310310
if msrs_written as u32 == msrs.as_fam_struct_ref().nmsrs {
311311
Ok(())
312312
} else {
313-
Err(SetMSRsError::Incomplete)
313+
Err(SetMsrsError::Incomplete)
314314
}
315315
})
316316
}

src/vmm/src/vstate/vcpu/x86_64.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use versionize::{VersionMap, Versionize, VersionizeError, VersionizeResult};
1818
use versionize_derive::Versionize;
1919

2020
use crate::arch::x86_64::interrupts;
21-
use crate::arch::x86_64::msr::{SetMSRsError, MSR_IA32_ARCH_CAPABILITIES};
21+
use crate::arch::x86_64::msr::{SetMsrsError, MSR_IA32_ARCH_CAPABILITIES};
2222
use crate::arch::x86_64::regs::{SetupFpuError, SetupRegistersError, SetupSpecialRegistersError};
2323
use crate::vstate::vcpu::{VcpuConfig, VcpuEmulation};
2424
use crate::vstate::vm::Vm;
@@ -47,19 +47,19 @@ pub enum Error {
4747
Fam(utils::fam::Error),
4848
/// Error configuring the floating point related registers
4949
#[error("Error configuring the floating point related registers: {0:?}")]
50-
FPUConfiguration(crate::arch::x86_64::regs::Error),
50+
FpuConfiguration(crate::arch::x86_64::regs::Error),
5151
/// Cannot set the local interruption due to bad configuration.
5252
#[error("Cannot set the local interruption due to bad configuration: {0:?}")]
5353
LocalIntConfiguration(crate::arch::x86_64::interrupts::Error),
5454
/// Error configuring the MSR registers
5555
#[error("Error configuring the MSR registers: {0:?}")]
56-
MSRSConfiguration(crate::arch::x86_64::msr::Error),
56+
MsrsConfiguration(crate::arch::x86_64::msr::Error),
5757
/// Error configuring the general purpose registers
5858
#[error("Error configuring the general purpose registers: {0:?}")]
59-
REGSConfiguration(crate::arch::x86_64::regs::Error),
59+
RegsConfiguration(crate::arch::x86_64::regs::Error),
6060
/// Error configuring the special registers
6161
#[error("Error configuring the special registers: {0:?}")]
62-
SREGSConfiguration(crate::arch::x86_64::regs::Error),
62+
SregsConfiguration(crate::arch::x86_64::regs::Error),
6363
/// Cannot open the VCPU file descriptor.
6464
#[error("Cannot open the VCPU file descriptor: {0}")]
6565
VcpuFd(kvm_ioctls::Error),
@@ -74,7 +74,7 @@ pub enum Error {
7474
VcpuGetMpState(kvm_ioctls::Error),
7575
/// The number of MSRS returned by the kernel is unexpected.
7676
#[error("Unexpected number of MSRS reported by the kernel")]
77-
VcpuGetMSRSIncomplete,
77+
VcpuGetMsrsIncomplete,
7878
/// Failed to get KVM vcpu msrs.
7979
#[error("Failed to get KVM vcpu msrs: {0}")]
8080
VcpuGetMsrs(kvm_ioctls::Error),
@@ -98,7 +98,7 @@ pub enum Error {
9898
VcpuGetCpuid(kvm_ioctls::Error),
9999
/// Failed to get KVM TSC freq.
100100
#[error("Failed to get KVM TSC frequency: {0}")]
101-
VcpuGetTSC(kvm_ioctls::Error),
101+
VcpuGetTsc(kvm_ioctls::Error),
102102
/// Failed to set KVM vcpu cpuid.
103103
#[error("Failed to set KVM vcpu cpuid: {0}")]
104104
VcpuSetCpuid(kvm_ioctls::Error),
@@ -116,7 +116,7 @@ pub enum Error {
116116
VcpuSetMsrs(kvm_ioctls::Error),
117117
/// Failed to set all KVM vcpu MSRs. Only a partial set was done.
118118
#[error("Failed to set all KVM MSRs for this vCPU. Only a partial write was done.")]
119-
VcpuSetMSRSIncomplete,
119+
VcpuSetMsrsIncomplete,
120120
/// Failed to set KVM vcpu regs.
121121
#[error("Failed to set KVM vcpu regs: {0}")]
122122
VcpuSetRegs(kvm_ioctls::Error),
@@ -134,7 +134,7 @@ pub enum Error {
134134
VcpuSetXsave(kvm_ioctls::Error),
135135
/// Failed to set KVM TSC freq.
136136
#[error("Failed to set KVM TSC frequency: {0}")]
137-
VcpuSetTSC(kvm_ioctls::Error),
137+
VcpuSetTsc(kvm_ioctls::Error),
138138
/// Failed to apply CPU template.
139139
#[error("Failed to apply CPU template")]
140140
VcpuTemplateError,
@@ -172,7 +172,7 @@ pub enum KvmVcpuConfigureError {
172172
#[error("Failed to get MSRs to save from CPUID: {0}")]
173173
MsrsToSaveByCpuid(crate::guest_config::cpuid::common::Leaf0NotFoundInCpuid),
174174
#[error("Failed to set MSRs: {0}")]
175-
SetMsrs(#[from] SetMSRsError),
175+
SetMsrs(#[from] SetMsrsError),
176176
#[error("Failed to setup registers: {0}")]
177177
SetupRegisters(#[from] SetupRegistersError),
178178
#[error("Failed to setup FPU: {0}")]
@@ -353,7 +353,7 @@ impl KvmVcpu {
353353
let expected_nmsrs = msrs.as_slice().len();
354354
let nmsrs = self.fd.get_msrs(msrs).map_err(Error::VcpuGetMsrs)?;
355355
if nmsrs != expected_nmsrs {
356-
return Err(Error::VcpuGetMSRSIncomplete);
356+
return Err(Error::VcpuGetMsrsIncomplete);
357357
}
358358
}
359359
let vcpu_events = self
@@ -450,7 +450,7 @@ impl KvmVcpu {
450450
for msrs in &state.saved_msrs {
451451
let nmsrs = self.fd.set_msrs(msrs).map_err(Error::VcpuSetMsrs)?;
452452
if nmsrs < msrs.as_fam_struct_ref().nmsrs as usize {
453-
return Err(Error::VcpuSetMSRSIncomplete);
453+
return Err(Error::VcpuSetMsrsIncomplete);
454454
}
455455
}
456456
self.fd

src/vmm/src/vstate/vm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::arch::aarch64::gic::GicState;
3030
pub enum Error {
3131
#[cfg(target_arch = "x86_64")]
3232
/// Retrieving supported guest MSRs fails.
33-
GuestMSRs(crate::arch::x86_64::msr::Error),
33+
GuestMsrs(crate::arch::x86_64::msr::Error),
3434
/// The number of configured slots is bigger than the maximum reported by KVM.
3535
NotEnoughMemorySlots,
3636
/// Cannot set the memory regions.
@@ -101,7 +101,7 @@ impl fmt::Display for Error {
101101

102102
match self {
103103
#[cfg(target_arch = "x86_64")]
104-
GuestMSRs(err) => write!(f, "Retrieving supported guest MSRs fails: {:?}", err),
104+
GuestMsrs(err) => write!(f, "Retrieving supported guest MSRs fails: {:?}", err),
105105
#[cfg(target_arch = "aarch64")]
106106
VmCreateGIC(err) => write!(
107107
f,
@@ -276,7 +276,7 @@ impl Vm {
276276
.get_supported_cpuid(KVM_MAX_CPUID_ENTRIES)
277277
.map_err(Error::VmFd)?;
278278
let supported_msrs =
279-
crate::arch::x86_64::msr::supported_guest_msrs(kvm).map_err(Error::GuestMSRs)?;
279+
crate::arch::x86_64::msr::supported_guest_msrs(kvm).map_err(Error::GuestMsrs)?;
280280

281281
Ok(Vm {
282282
fd: vm_fd,

0 commit comments

Comments
 (0)