vmm: Address Rust 1.51.0 clippy issue (upper_case_acroynms)

warning: name `LocalAPIC` contains a capitalized acronym
   --> vmm/src/cpu.rs:197:8
    |
197 | struct LocalAPIC {
    |        ^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `LocalApic`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2021-03-25 17:01:21 +00:00
parent 7c302373ed
commit 9762c8bc28
7 changed files with 49 additions and 49 deletions

View File

@ -17,7 +17,7 @@ use vm_memory::{Address, ByteValued, Bytes, GuestAddress, GuestMemoryMmap, Guest
#[repr(packed)]
#[derive(Default)]
struct PCIRangeEntry {
struct PciRangeEntry {
pub base_address: u64,
pub segment: u16,
pub start: u8,
@ -188,7 +188,7 @@ pub fn create_acpi_tables(
mcfg.append(0u64);
// 32-bit PCI enhanced configuration mechanism
mcfg.append(PCIRangeEntry {
mcfg.append(PciRangeEntry {
base_address: arch::layout::PCI_MMCONFIG_START.0,
segment: 0,
start: 0,

View File

@ -261,7 +261,7 @@ pub fn start_http_thread(
) -> Result<thread::JoinHandle<Result<()>>> {
std::fs::remove_file(path).unwrap_or_default();
let socket_path = PathBuf::from(path);
let mut server = HttpServer::new(socket_path).map_err(Error::CreatingAPIServer)?;
let mut server = HttpServer::new(socket_path).map_err(Error::CreateApiServer)?;
// Retrieve seccomp filter for API thread
let api_seccomp_filter =

View File

@ -55,7 +55,7 @@ pub enum Error {
/// Error parsing network options
ParseNetwork(OptionParserError),
/// Error parsing RNG options
ParseRNG(OptionParserError),
ParseRng(OptionParserError),
/// Error parsing balloon options
ParseBalloon(OptionParserError),
/// Error parsing filesystem parameters
@ -195,7 +195,7 @@ impl fmt::Display for Error {
ParseMemoryZoneIdMissing => write!(f, "Error parsing --memory-zone: id missing"),
ParseNetwork(o) => write!(f, "Error parsing --net: {}", o),
ParseDisk(o) => write!(f, "Error parsing --disk: {}", o),
ParseRNG(o) => write!(f, "Error parsing --rng: {}", o),
ParseRng(o) => write!(f, "Error parsing --rng: {}", o),
ParseBalloon(o) => write!(f, "Error parsing --balloon: {}", o),
ParseRestore(o) => write!(f, "Error parsing --restore: {}", o),
#[cfg(target_arch = "x86_64")]
@ -1036,7 +1036,7 @@ impl RngConfig {
pub fn parse(rng: &str) -> Result<Self> {
let mut parser = OptionParser::new();
parser.add("src").add("iommu");
parser.parse(rng).map_err(Error::ParseRNG)?;
parser.parse(rng).map_err(Error::ParseRng)?;
let src = PathBuf::from(
parser
@ -1045,7 +1045,7 @@ impl RngConfig {
);
let iommu = parser
.convert::<Toggle>("iommu")
.map_err(Error::ParseRNG)?
.map_err(Error::ParseRng)?
.unwrap_or(Toggle(false))
.0;

View File

@ -101,7 +101,7 @@ pub enum Error {
BusError(vm_device::BusError),
/// Asking for more vCPUs that we can have
DesiredVCPUCountExceedsMax,
DesiredVCpuCountExceedsMax,
/// Failed to get KVM vcpu lapic.
VcpuGetLapic(anyhow::Error),
@ -173,15 +173,15 @@ pub enum Error {
UnexpectedVmExit,
/// Failed to allocate MMIO address
AllocateMMIOAddress,
AllocateMmmioAddress,
/// Error populating CPUID with KVM HyperV emulation details
#[cfg(target_arch = "x86_64")]
CpuidKVMHyperV(vmm_sys_util::fam::Error),
CpuidKvmHyperV(vmm_sys_util::fam::Error),
/// Error populating CPUID with KVM HyperV emulation details
#[cfg(target_arch = "x86_64")]
CpuidSGX(arch::x86_64::Error),
CpuidSgx(arch::x86_64::Error),
/// Error populating CPUID with CPU identification
#[cfg(target_arch = "x86_64")]
@ -194,7 +194,7 @@ pub type Result<T> = result::Result<T, Error>;
#[cfg(feature = "acpi")]
#[repr(packed)]
struct LocalAPIC {
struct LocalApic {
pub r#type: u8,
pub length: u8,
pub processor_id: u8,
@ -204,7 +204,7 @@ struct LocalAPIC {
#[repr(packed)]
#[derive(Default)]
struct IOAPIC {
struct Ioapic {
pub r#type: u8,
pub length: u8,
pub ioapic_id: u8,
@ -585,7 +585,7 @@ impl CpuManager {
.lock()
.unwrap()
.allocate_mmio_addresses(None, CPU_MANAGER_ACPI_SIZE as u64, None)
.ok_or(Error::AllocateMMIOAddress)?;
.ok_or(Error::AllocateMmmioAddress)?;
let cpu_manager = Arc::new(Mutex::new(CpuManager {
config: config.clone(),
interrupt_controller: device_manager.interrupt_controller().clone(),
@ -680,7 +680,7 @@ impl CpuManager {
if let Some(sgx_epc_sections) = sgx_epc_sections {
arch::x86_64::update_cpuid_sgx(&mut cpuid, sgx_epc_sections)
.map_err(Error::CpuidSGX)?;
.map_err(Error::CpuidSgx)?;
}
// Set CPU physical bits
@ -721,14 +721,14 @@ impl CpuManager {
edx: 0x7648204d, // "M Hv"
..Default::default()
})
.map_err(Error::CpuidKVMHyperV)?;
.map_err(Error::CpuidKvmHyperV)?;
cpuid
.push(CpuIdEntry {
function: 0x40000001,
eax: 0x31237648, // "Hv#1"
..Default::default()
})
.map_err(Error::CpuidKVMHyperV)?;
.map_err(Error::CpuidKvmHyperV)?;
cpuid
.push(CpuIdEntry {
function: 0x40000002,
@ -736,7 +736,7 @@ impl CpuManager {
ebx: 0xa0000, // "Version"
..Default::default()
})
.map_err(Error::CpuidKVMHyperV)?;
.map_err(Error::CpuidKvmHyperV)?;
cpuid
.push(CpuIdEntry {
function: 0x4000_0003,
@ -746,14 +746,14 @@ impl CpuManager {
| 1 << 9, // AccessPartitionReferenceTsc
..Default::default()
})
.map_err(Error::CpuidKVMHyperV)?;
.map_err(Error::CpuidKvmHyperV)?;
for i in 0x4000_0004..=0x4000_000a {
cpuid
.push(CpuIdEntry {
function: i,
..Default::default()
})
.map_err(Error::CpuidKVMHyperV)?;
.map_err(Error::CpuidKvmHyperV)?;
}
}
@ -817,7 +817,7 @@ impl CpuManager {
);
if desired_vcpus > self.config.max_vcpus {
return Err(Error::DesiredVCPUCountExceedsMax);
return Err(Error::DesiredVCpuCountExceedsMax);
}
// Only create vCPUs in excess of all the allocated vCPUs.
@ -970,7 +970,7 @@ impl CpuManager {
/// Start up as many vCPUs threads as needed to reach `desired_vcpus`
fn activate_vcpus(&mut self, desired_vcpus: u8, inserting: bool) -> Result<()> {
if desired_vcpus > self.config.max_vcpus {
return Err(Error::DesiredVCPUCountExceedsMax);
return Err(Error::DesiredVCpuCountExceedsMax);
}
let vcpu_thread_barrier = Arc::new(Barrier::new(
@ -1144,7 +1144,7 @@ impl CpuManager {
madt.write(36, arch::layout::APIC_START);
for cpu in 0..self.config.max_vcpus {
let lapic = LocalAPIC {
let lapic = LocalApic {
r#type: 0,
length: 8,
processor_id: cpu,
@ -1158,7 +1158,7 @@ impl CpuManager {
madt.append(lapic);
}
madt.append(IOAPIC {
madt.append(Ioapic {
r#type: 1,
length: 12,
ioapic_id: 0,
@ -1187,7 +1187,7 @@ impl CpuManager {
}
#[cfg(feature = "acpi")]
struct CPU {
struct Cpu {
cpu_id: u8,
}
@ -1195,9 +1195,9 @@ struct CPU {
const MADT_CPU_ENABLE_FLAG: usize = 0;
#[cfg(feature = "acpi")]
impl Aml for CPU {
impl Aml for Cpu {
fn to_aml_bytes(&self) -> Vec<u8> {
let lapic = LocalAPIC {
let lapic = LocalApic {
r#type: 0,
length: 8,
processor_id: self.cpu_id,
@ -1207,7 +1207,7 @@ impl Aml for CPU {
let mut mat_data: Vec<u8> = Vec::new();
mat_data.resize(std::mem::size_of_val(&lapic), 0);
unsafe { *(mat_data.as_mut_ptr() as *mut LocalAPIC) = lapic };
unsafe { *(mat_data.as_mut_ptr() as *mut LocalApic) = lapic };
aml::Device::new(
format!("C{:03}", self.cpu_id).as_str().into(),
@ -1252,12 +1252,12 @@ impl Aml for CPU {
}
#[cfg(feature = "acpi")]
struct CPUNotify {
struct CpuNotify {
cpu_id: u8,
}
#[cfg(feature = "acpi")]
impl Aml for CPUNotify {
impl Aml for CpuNotify {
fn to_aml_bytes(&self) -> Vec<u8> {
let object = aml::Path::new(&format!("C{:03}", self.cpu_id));
aml::If::new(
@ -1269,12 +1269,12 @@ impl Aml for CPUNotify {
}
#[cfg(feature = "acpi")]
struct CPUMethods {
struct CpuMethods {
max_vcpus: u8,
}
#[cfg(feature = "acpi")]
impl Aml for CPUMethods {
impl Aml for CpuMethods {
fn to_aml_bytes(&self) -> Vec<u8> {
let mut bytes = Vec::new();
bytes.extend_from_slice(
@ -1305,7 +1305,7 @@ impl Aml for CPUMethods {
let mut cpu_notifies = Vec::new();
for cpu_id in 0..self.max_vcpus {
cpu_notifies.push(CPUNotify { cpu_id });
cpu_notifies.push(CpuNotify { cpu_id });
}
let mut cpu_notifies_refs: Vec<&dyn aml::Aml> = Vec::new();
@ -1455,14 +1455,14 @@ impl Aml for CpuManager {
let hid = aml::Name::new("_HID".into(), &"ACPI0010");
let uid = aml::Name::new("_CID".into(), &aml::EisaName::new("PNP0A05"));
// Bundle methods together under a common object
let methods = CPUMethods {
let methods = CpuMethods {
max_vcpus: self.config.max_vcpus,
};
let mut cpu_data_inner: Vec<&dyn aml::Aml> = vec![&hid, &uid, &methods];
let mut cpu_devices = Vec::new();
for cpu_id in 0..self.config.max_vcpus {
let cpu_device = CPU { cpu_id };
let cpu_device = Cpu { cpu_id };
cpu_devices.push(cpu_device);
}

View File

@ -278,10 +278,10 @@ pub enum DeviceManagerError {
BusError(vm_device::BusError),
/// Failed to allocate IO port
AllocateIOPort,
AllocateIoPort,
/// Failed to allocate MMIO address
AllocateMMIOAddress,
AllocateMmioAddress,
// Failed to make hotplug notification
HotPlugNotification(io::Error),
@ -432,13 +432,13 @@ const DEVICE_MANAGER_ACPI_SIZE: usize = 0x10;
pub fn get_win_size() -> (u16, u16) {
#[repr(C)]
#[derive(Default)]
struct WS {
struct WindowSize {
rows: u16,
cols: u16,
xpixel: u16,
ypixel: u16,
}
let ws: WS = WS::default();
let ws: WindowSize = WindowSize::default();
unsafe {
libc::ioctl(0, TIOCGWINSZ, &ws);
@ -983,7 +983,7 @@ impl DeviceManager {
.lock()
.unwrap()
.allocate_mmio_addresses(None, DEVICE_MANAGER_ACPI_SIZE as u64, None)
.ok_or(DeviceManagerError::AllocateIOPort)?;
.ok_or(DeviceManagerError::AllocateIoPort)?;
let device_manager = DeviceManager {
address_manager: Arc::clone(&address_manager),
console: Arc::new(Console::default()),
@ -1394,7 +1394,7 @@ impl DeviceManager {
.lock()
.unwrap()
.allocate_io_addresses(Some(GuestAddress(0x3c0)), 0x8, None)
.ok_or(DeviceManagerError::AllocateIOPort)?;
.ok_or(DeviceManagerError::AllocateIoPort)?;
self.address_manager
.io_bus
@ -1420,7 +1420,7 @@ impl DeviceManager {
.lock()
.unwrap()
.allocate_mmio_addresses(None, devices::acpi::GED_DEVICE_ACPI_SIZE as u64, None)
.ok_or(DeviceManagerError::AllocateMMIOAddress)?;
.ok_or(DeviceManagerError::AllocateMmioAddress)?;
let ged_device = Arc::new(Mutex::new(devices::AcpiGEDDevice::new(
interrupt_group,
ged_irq,
@ -1449,7 +1449,7 @@ impl DeviceManager {
.lock()
.unwrap()
.allocate_io_addresses(Some(GuestAddress(0xb008)), 0x4, None)
.ok_or(DeviceManagerError::AllocateIOPort)?;
.ok_or(DeviceManagerError::AllocateIoPort)?;
self.address_manager
.io_bus
@ -1638,7 +1638,7 @@ impl DeviceManager {
.lock()
.unwrap()
.allocate_io_addresses(Some(GuestAddress(0x3f8)), 0x8, None)
.ok_or(DeviceManagerError::AllocateIOPort)?;
.ok_or(DeviceManagerError::AllocateIoPort)?;
self.address_manager
.io_bus

View File

@ -143,7 +143,7 @@ pub enum Error {
/// Error creating API server
#[error("Error creating API server {0:?}")]
CreatingAPIServer(micro_http::ServerError),
CreateApiServer(micro_http::ServerError),
}
pub type Result<T> = result::Result<T, Error>;

View File

@ -172,7 +172,7 @@ pub enum Error {
NoSlotAvailable,
/// Not enough space in the hotplug RAM region
InsufficientHotplugRAM,
InsufficientHotplugRam,
/// The requested hotplug memory addition is not a valid size
InvalidSize,
@ -267,7 +267,7 @@ pub enum Error {
SnapshotCopy(GuestMemoryError),
/// Failed to allocate MMIO address
AllocateMMIOAddress,
AllocateMmioAddress,
}
const ENABLE_FLAG: usize = 0;
@ -741,7 +741,7 @@ impl MemoryManager {
.lock()
.unwrap()
.allocate_mmio_addresses(None, MEMORY_MANAGER_ACPI_SIZE as u64, None)
.ok_or(Error::AllocateMMIOAddress)?;
.ok_or(Error::AllocateMmioAddress)?;
#[cfg(not(feature = "tdx"))]
let log_dirty = true;
@ -1160,7 +1160,7 @@ impl MemoryManager {
let start_addr = MemoryManager::start_addr(self.guest_memory.memory().last_addr(), true)?;
if start_addr.checked_add(size.try_into().unwrap()).unwrap() > self.start_of_device_area() {
return Err(Error::InsufficientHotplugRAM);
return Err(Error::InsufficientHotplugRam);
}
let region = self.add_ram_region(start_addr, size)?;