ci: Run clippy for each specific feature

The build is run against "--all-features", "pci,acpi", "pci" and "mmio"
separately. The clippy validation must be run against the same set of
features in order to validate the code is correct.

Because of these new checks, this commit includes multiple fixes
related to the errors generated when manually running the checks.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2020-01-21 09:32:50 +01:00
parent e91638e6c5
commit 9ac06bf613
6 changed files with 28 additions and 5 deletions

View File

@@ -12,6 +12,7 @@ use crate::device_manager::DeviceManager;
#[cfg(feature = "acpi")]
use acpi_tables::{aml, aml::Aml, sdt::SDT};
use arc_swap::ArcSwap;
#[cfg(feature = "acpi")]
use arch::layout;
use devices::{ioapic, BusDevice};
use kvm_bindings::CpuId;
@@ -197,6 +198,7 @@ impl CpuidPatch {
}
}
#[cfg(feature = "acpi")]
#[repr(packed)]
struct LocalAPIC {
pub r#type: u8,
@@ -747,10 +749,12 @@ impl CpuManager {
}
}
#[cfg(feature = "acpi")]
struct CPU {
cpu_id: u8,
}
#[cfg(feature = "acpi")]
const MADT_CPU_ENABLE_FLAG: usize = 0;
#[cfg(feature = "acpi")]
@@ -813,6 +817,7 @@ impl Aml for CPU {
}
}
#[cfg(feature = "acpi")]
struct CPUNotify {
cpu_id: u8,
}
@@ -829,6 +834,7 @@ impl Aml for CPUNotify {
}
}
#[cfg(feature = "acpi")]
struct CPUMethods {
max_vcpus: u8,
}

View File

@@ -11,13 +11,16 @@
extern crate vm_device;
use crate::config::{ConsoleOutputMode, VmConfig};
use crate::config::ConsoleOutputMode;
#[cfg(feature = "acpi")]
use crate::config::VmConfig;
use crate::interrupt::{KvmInterruptManager, KvmRoutingEntry};
use crate::memory_manager::{Error as MemoryManagerError, MemoryManager};
use crate::vm::VmInfo;
#[cfg(feature = "acpi")]
use acpi_tables::{aml, aml::Aml};
use arc_swap::ArcSwap;
#[cfg(feature = "acpi")]
use arch::layout;
use arch::layout::{APIC_START, IOAPIC_SIZE, IOAPIC_START};
use devices::{ioapic, HotPlugNotificationFlags};
@@ -380,12 +383,14 @@ pub struct DeviceManager {
ged_notification_device: Option<Arc<Mutex<devices::AcpiGEDDevice>>>,
// VM configuration
#[cfg(feature = "acpi")]
config: Arc<Mutex<VmConfig>>,
// Migratable devices
migratable_devices: Vec<Arc<Mutex<dyn Migratable>>>,
// Memory Manager
#[cfg(feature = "acpi")]
memory_manager: Arc<Mutex<MemoryManager>>,
}
@@ -486,7 +491,10 @@ impl DeviceManager {
)?;
}
#[cfg(feature = "acpi")]
let config = vm_info.vm_cfg.clone();
#[cfg(feature = "acpi")]
let memory_manager_clone = memory_manager.clone();
address_manager
.allocator
@@ -497,7 +505,7 @@ impl DeviceManager {
address_manager
.io_bus
.insert(memory_manager.clone(), 0xa00, 0x18)
.insert(memory_manager, 0xa00, 0x18)
.map_err(DeviceManagerError::BusError)?;
Ok(DeviceManager {
@@ -509,9 +517,11 @@ impl DeviceManager {
virt_iommu,
#[cfg(feature = "acpi")]
ged_notification_device,
#[cfg(feature = "acpi")]
config,
migratable_devices,
memory_manager,
#[cfg(feature = "acpi")]
memory_manager: memory_manager_clone,
})
}

View File

@@ -462,6 +462,7 @@ impl MemoryManager {
}
}
#[cfg(feature = "acpi")]
struct MemoryNotify {
slot_id: usize,
}
@@ -478,6 +479,7 @@ impl Aml for MemoryNotify {
}
}
#[cfg(feature = "acpi")]
struct MemorySlot {
slot_id: usize,
}
@@ -534,6 +536,7 @@ impl Aml for MemorySlot {
}
}
#[cfg(feature = "acpi")]
struct MemorySlots {
slots: usize,
}
@@ -551,6 +554,7 @@ impl Aml for MemorySlots {
}
}
#[cfg(feature = "acpi")]
struct MemoryMethods {
slots: usize,
}

View File

@@ -695,7 +695,6 @@ mod tests {
assert!(state.valid_transition(VmState::Shutdown).is_ok());
assert!(state.valid_transition(VmState::Paused).is_err());
}
_ => {}
}
}