From bf217f7064cab7a0bde6705857b640c9ea0793e4 Mon Sep 17 00:00:00 2001 From: Joshua Job Date: Thu, 15 Jun 2023 15:47:04 -0700 Subject: [PATCH 1/3] Display: Add ability to skip sections The KVM and MSR sections can now be skipped when display is run. --- src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0f2a261..f26bf44 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,8 +36,13 @@ enum CommandOpts { #[derive(StructOpt)] struct Disp { - #[structopt(short, long)] + #[structopt(short = "r", long)] display_raw: bool, + #[cfg(all(target_os = "linux", feature = "kvm"))] + #[structopt(long)] + skip_kvm: bool, + #[structopt(long)] + skip_msr: bool, } impl Command for Disp { @@ -54,7 +59,7 @@ impl Command for Disp { } #[cfg(all(target_os = "linux", feature = "kvm"))] - { + if !self.skip_kvm { use cpuinfo::kvm::KvmInfo; use kvm_ioctls::Kvm; println!("KVM-CPUID:"); @@ -72,7 +77,7 @@ impl Command for Disp { } } - if MSRDesc::is_availible() { + if MSRDesc::is_availible() && self.skip_msr { println!("MSRS:"); for msr in &config.msrs { match msr.into_value() { From d6b9510eb5e53633727cf791cf88262a50f8338c Mon Sep 17 00:00:00 2001 From: Joshua Job Date: Fri, 25 Aug 2023 10:59:04 -0700 Subject: [PATCH 2/3] Fixed logic around new flag --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index f26bf44..7d55ab9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,7 +77,7 @@ impl Command for Disp { } } - if MSRDesc::is_availible() && self.skip_msr { + if MSRDesc::is_availible() && !self.skip_msr { println!("MSRS:"); for msr in &config.msrs { match msr.into_value() { From 1cd7bbdcbdf7b7131882028d39b5df455057b45b Mon Sep 17 00:00:00 2001 From: Joshua Job Date: Fri, 6 Oct 2023 16:16:34 -0700 Subject: [PATCH 3/3] Fixed misspelling --- Cargo.lock | 2 +- src/main.rs | 4 ++-- src/msr.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 84c9eac..04f1bda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,7 +51,7 @@ dependencies = [ [[package]] name = "cpuinfo" -version = "0.1.0" +version = "0.1.2" dependencies = [ "enum_dispatch", "kvm-bindings", diff --git a/src/main.rs b/src/main.rs index 7d55ab9..3ca8f70 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,7 +77,7 @@ impl Command for Disp { } } - if MSRDesc::is_availible() && !self.skip_msr { + if MSRDesc::is_available() && !self.skip_msr { println!("MSRS:"); for msr in &config.msrs { match msr.into_value() { @@ -119,7 +119,7 @@ fn collect_facts( CpuidType::KvmInfo(_) => true, }; - if MSRDesc::is_availible() && !use_kvm { + if MSRDesc::is_available() && !use_kvm { for msr in &config.msrs { if let Ok(value) = MSRValue::try_from(msr) { let mut facts = value.collect_facts(); diff --git a/src/msr.rs b/src/msr.rs index 619b4ee..6e7ce75 100644 --- a/src/msr.rs +++ b/src/msr.rs @@ -69,7 +69,7 @@ impl MSRDesc { Ok(u64::from_le_bytes(msr_bytes)) } #[cfg(all(target_os = "linux", feature = "use_msr"))] - pub fn is_availible() -> bool { + pub fn is_available() -> bool { true } @@ -78,7 +78,7 @@ impl MSRDesc { Err(Error::NotAvailible) } #[cfg(any(not(target_os = "linux"), not(feature = "use_msr")))] - pub fn is_availible() -> bool { + pub fn is_available() -> bool { false }