implemented generic linux sal with heuristics
This commit is contained in:
@@ -17,6 +17,7 @@ pub struct DellXps9380Sal {
|
||||
last_poll: Mutex<Instant>,
|
||||
last_temp: Mutex<f32>,
|
||||
last_fans: Mutex<Vec<u32>>,
|
||||
suppressed_services: Mutex<Vec<String>>,
|
||||
}
|
||||
|
||||
impl DellXps9380Sal {
|
||||
@@ -82,6 +83,7 @@ impl DellXps9380Sal {
|
||||
last_poll: Mutex::new(Instant::now() - Duration::from_secs(2)),
|
||||
last_temp: Mutex::new(0.0),
|
||||
last_fans: Mutex::new(Vec::new()),
|
||||
suppressed_services: Mutex::new(Vec::new()),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -151,44 +153,36 @@ impl PreflightAuditor for DellXps9380Sal {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DellXps9380Guard {
|
||||
stopped_services: Vec<String>,
|
||||
}
|
||||
|
||||
impl DellXps9380Guard {
|
||||
pub fn new() -> Self {
|
||||
Self { stopped_services: Vec::new() }
|
||||
}
|
||||
}
|
||||
|
||||
impl EnvironmentGuard for DellXps9380Guard {
|
||||
impl EnvironmentGuard for DellXps9380Sal {
|
||||
fn suppress(&mut self) -> Result<()> {
|
||||
let services = ["tlp", "thermald", "i8kmon"];
|
||||
let mut suppressed = self.suppressed_services.lock().unwrap();
|
||||
for s in services {
|
||||
if Command::new("systemctl").args(["is-active", "--quiet", s]).status()?.success() {
|
||||
debug!("Suppressing service: {}", s);
|
||||
Command::new("systemctl").args(["stop", s]).status()?;
|
||||
self.stopped_services.push(s.to_string());
|
||||
suppressed.push(s.to_string());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn restore(&mut self) -> Result<()> {
|
||||
for s in &self.stopped_services {
|
||||
let _ = Command::new("systemctl").args(["start", s]).status();
|
||||
let mut suppressed = self.suppressed_services.lock().unwrap();
|
||||
for s in suppressed.drain(..) {
|
||||
let _ = Command::new("systemctl").args(["start", &s]).status();
|
||||
}
|
||||
self.stopped_services.clear();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for DellXps9380Guard {
|
||||
impl Drop for DellXps9380Sal {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.restore();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl SensorBus for DellXps9380Sal {
|
||||
fn get_temp(&self) -> Result<f32> {
|
||||
// Enforce 1000ms rate limit for Dell SMM as per GEMINI.md
|
||||
|
||||
Reference in New Issue
Block a user