From 5b1eb08bdeb186e7b7afa117b65b95f255162c4c Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 14 Jul 2021 12:32:10 +1000 Subject: [PATCH] agent/uevent: Improve logging of wait_for_uevent() These messages will help when debugging matchers not matching properly. Signed-off-by: David Gibson --- src/agent/src/uevent.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/agent/src/uevent.rs b/src/agent/src/uevent.rs index c5ecefcc19..1b1dbb72e8 100644 --- a/src/agent/src/uevent.rs +++ b/src/agent/src/uevent.rs @@ -111,10 +111,13 @@ pub async fn wait_for_uevent( sandbox: &Arc>, matcher: impl UeventMatcher, ) -> Result { + let logprefix = format!("Waiting for {:?}", &matcher); + + info!(sl!(), "{}", logprefix); let mut sb = sandbox.lock().await; for uev in sb.uevent_map.values() { if matcher.is_match(uev) { - info!(sl!(), "Device {:?} found in device map", uev); + info!(sl!(), "{}: found {:?} in uevent map", logprefix, &uev); return Ok(uev.clone()); } } @@ -129,7 +132,8 @@ pub async fn wait_for_uevent( sb.uevent_watchers.push(Some((Box::new(matcher), tx))); drop(sb); // unlock - info!(sl!(), "Waiting on channel for uevent notification\n"); + info!(sl!(), "{}: waiting on channel", logprefix); + let hotplug_timeout = AGENT_CONFIG.read().await.hotplug_timeout; let uev = match tokio::time::timeout(hotplug_timeout, rx).await { @@ -146,6 +150,7 @@ pub async fn wait_for_uevent( } }; + info!(sl!(), "{}: found {:?} on channel", logprefix, &uev); Ok(uev) }