let mut collector_memory = MemorySource::new()?;
+ // Remove old entries from previous agent to avoid having unknown
+ // interfaces. We will repopulate existing ones immediatly.
+ publisher.cleanup_ifaces()?;
+
let kernel_info = collect_kernel()?;
let mem_total_kb = match collector_memory.get_total_kb() {
Ok(mem_total_kb) => Some(mem_total_kb),
}
Ok(())
}
+
+ pub fn cleanup_ifaces(&mut self) -> io::Result<()> {
+ Ok(())
+ }
}
) -> io::Result<()>;
fn publish_memfree(&self, mem_free_kb: usize) -> io::Result<()>;
fn publish_netevent(&mut self, event: &NetEvent) -> io::Result<()>;
+ fn cleanup_ifaces(&mut self) -> io::Result<()>;
}
pub struct Publisher {
pub fn publish_netevent(&mut self, event: &NetEvent) -> io::Result<()> {
self.schema.publish_netevent(event)
}
+
+ pub fn cleanup_ifaces(&mut self) -> io::Result<()> {
+ self.schema.cleanup_ifaces()
+ }
}
fn schema_from_name(name: &str) -> io::Result<&'static dyn Fn(Xs) -> Box<dyn XenstoreSchema>> {
Ok(())
}
+ fn cleanup_ifaces(&mut self) -> io::Result<()> {
+ // Currently only vif interfaces are cleaned
+ xs_unpublish(&self.xs, "data/net")
+ }
+
fn publish_memfree(&self, _mem_free_kb: usize) -> io::Result<()> {
//xs_publish(&self.xs, "data/meminfo_free", &mem_free_kb.to_string())?;
Ok(())
}
Ok(())
}
+
+ fn cleanup_ifaces(&mut self) -> io::Result<()> {
+ // Currently only vif interfaces are cleaned
+ xs_unpublish(&self.xs, "attr/vif")
+ }
}
impl Schema {