mirror of
				https://github.com/kata-containers/kata-containers.git
				synced 2025-10-30 08:52:39 +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:
		| @@ -94,6 +94,7 @@ pub const SYSTEM_DEV_PATH: &str = "/dev"; | |||||||
| // Linux UEvent related consts. | // Linux UEvent related consts. | ||||||
| pub const U_EVENT_ACTION: &str = "ACTION"; | pub const U_EVENT_ACTION: &str = "ACTION"; | ||||||
| pub const U_EVENT_ACTION_ADD: &str = "add"; | 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_DEV_PATH: &str = "DEVPATH"; | ||||||
| pub const U_EVENT_SUB_SYSTEM: &str = "SUBSYSTEM"; | pub const U_EVENT_SUB_SYSTEM: &str = "SUBSYSTEM"; | ||||||
| pub const U_EVENT_SEQ_NUM: &str = "SEQNUM"; | 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] |     #[instrument] | ||||||
|     async fn process(&self, logger: &Logger, sandbox: &Arc<Mutex<Sandbox>>) { |     async fn process(&self, logger: &Logger, sandbox: &Arc<Mutex<Sandbox>>) { | ||||||
|         if self.action == U_EVENT_ACTION_ADD { |         if self.action == U_EVENT_ACTION_ADD { | ||||||
|             return self.process_add(logger, sandbox).await; |             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)); |         debug!(*logger, "ignoring event"; "uevent" => format!("{:?}", self)); | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user