diff --git a/arch/src/x86_64/tdx/mod.rs b/arch/src/x86_64/tdx/mod.rs index 0f2eb8d43..43bdb3641 100644 --- a/arch/src/x86_64/tdx/mod.rs +++ b/arch/src/x86_64/tdx/mod.rs @@ -46,7 +46,7 @@ pub struct TdvfSection { } #[repr(u32)] -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Default)] pub enum TdvfSectionType { Bfv, Cfv, @@ -55,15 +55,10 @@ pub enum TdvfSectionType { PermMem, Payload, PayloadParam, + #[default] Reserved = 0xffffffff, } -impl Default for TdvfSectionType { - fn default() -> Self { - TdvfSectionType::Reserved - } -} - pub fn parse_tdvf_sections(file: &mut File) -> Result, TdvfError> { // The 32-bit offset to the TDVF metadata is located 32 bytes from // the end of the file. @@ -120,21 +115,16 @@ pub fn parse_tdvf_sections(file: &mut File) -> Result, TdvfErro } #[repr(u16)] -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, Default)] enum HobType { Handoff = 0x1, ResourceDescriptor = 0x3, GuidExtension = 0x4, + #[default] Unused = 0xfffe, EndOfHobList = 0xffff, } -impl Default for HobType { - fn default() -> Self { - HobType::Unused - } -} - #[repr(C)] #[derive(Copy, Clone, Default, Debug)] struct HobHeader { @@ -184,19 +174,14 @@ struct HobGuidType { } #[repr(u32)] -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Default)] pub enum PayloadImageType { + #[default] ExecutablePayload, BzImage, RawVmLinux, } -impl Default for PayloadImageType { - fn default() -> Self { - PayloadImageType::ExecutablePayload - } -} - #[repr(C)] #[derive(Copy, Clone, Default, Debug)] pub struct PayloadInfo { diff --git a/performance-metrics/src/performance_tests.rs b/performance-metrics/src/performance_tests.rs index 707ee8719..07dbcbd50 100644 --- a/performance-metrics/src/performance_tests.rs +++ b/performance-metrics/src/performance_tests.rs @@ -168,7 +168,6 @@ fn parse_boot_time_output(output: &[u8]) -> Result { std::panic::catch_unwind(|| { let l: Vec = String::from_utf8_lossy(output) .lines() - .into_iter() .filter(|l| l.contains("Debug I/O port: Kernel code")) .map(|l| l.to_string()) .collect(); diff --git a/vfio_user/src/lib.rs b/vfio_user/src/lib.rs index f97769558..24187f9ea 100644 --- a/vfio_user/src/lib.rs +++ b/vfio_user/src/lib.rs @@ -24,8 +24,9 @@ extern crate log; #[allow(dead_code)] #[repr(u16)] -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Default)] enum Command { + #[default] Unknown = 0, Version = 1, DmaMap = 2, @@ -43,28 +44,17 @@ enum Command { UserDirtyPages = 14, } -impl Default for Command { - fn default() -> Self { - Command::Unknown - } -} - #[allow(dead_code)] #[repr(u32)] -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] enum HeaderFlags { + #[default] Command = 0, Reply = 1, NoReply = 1 << 4, Error = 1 << 5, } -impl Default for HeaderFlags { - fn default() -> Self { - HeaderFlags::Command - } -} - #[repr(C)] #[derive(Default, Clone, Copy, Debug)] struct Header { diff --git a/vmm/src/vm_config.rs b/vmm/src/vm_config.rs index 6a5f9d22b..8286f5fe1 100644 --- a/vmm/src/vm_config.rs +++ b/vmm/src/vm_config.rs @@ -127,18 +127,13 @@ pub struct MemoryZoneConfig { pub prefault: bool, } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize, Default)] pub enum HotplugMethod { + #[default] Acpi, VirtioMem, } -impl Default for HotplugMethod { - fn default() -> Self { - HotplugMethod::Acpi - } -} - fn default_memoryconfig_thp() -> bool { true } @@ -188,18 +183,13 @@ impl Default for MemoryConfig { } } -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)] pub enum VhostMode { + #[default] Client, Server, } -impl Default for VhostMode { - fn default() -> Self { - VhostMode::Client - } -} - #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub struct DiskConfig { pub path: Option,