mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
agent: Handle uevent remove actions
uevents with action=remove was ignored causing the agent to reuse stale data in the device map. This patch adds handling of such uevents. Fixes #2405 Signed-off-by: Haitao Li <lihaitao@gmail.com>
This commit is contained in:
parent
03877f3479
commit
a13e2f77b8
@ -94,6 +94,7 @@ pub const SYSTEM_DEV_PATH: &str = "/dev";
|
||||
// Linux UEvent related consts.
|
||||
pub const U_EVENT_ACTION: &str = "ACTION";
|
||||
pub const U_EVENT_ACTION_ADD: &str = "add";
|
||||
pub const U_EVENT_ACTION_REMOVE: &str = "remove";
|
||||
pub const U_EVENT_DEV_PATH: &str = "DEVPATH";
|
||||
pub const U_EVENT_SUB_SYSTEM: &str = "SUBSYSTEM";
|
||||
pub const U_EVENT_SEQ_NUM: &str = "SEQNUM";
|
||||
|
@ -97,10 +97,18 @@ impl Uevent {
|
||||
})
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn process_remove(&self, logger: &Logger, sandbox: &Arc<Mutex<Sandbox>>) {
|
||||
let mut sb = sandbox.lock().await;
|
||||
sb.uevent_map.remove(&self.devpath);
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn process(&self, logger: &Logger, sandbox: &Arc<Mutex<Sandbox>>) {
|
||||
if self.action == U_EVENT_ACTION_ADD {
|
||||
return self.process_add(logger, sandbox).await;
|
||||
} else if self.action == U_EVENT_ACTION_REMOVE {
|
||||
return self.process_remove(logger, sandbox).await;
|
||||
}
|
||||
debug!(*logger, "ignoring event"; "uevent" => format!("{:?}", self));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user