From c1b4fcc7505b4deebbfa68caf13bfc89f3ff36c0 Mon Sep 17 00:00:00 2001 From: Dylan Reid Date: Thu, 16 Apr 2026 09:43:16 -0700 Subject: [PATCH] virtio-devices: More detailed vhost user errors Make it easier to chase down which vhost user socket failed and why in systems that have many vhost user devices. Signed-off-by: Dylan Reid --- virtio-devices/src/vhost_user/blk.rs | 11 +++++++++-- virtio-devices/src/vhost_user/fs.rs | 5 ++++- virtio-devices/src/vhost_user/generic_vhost_user.rs | 5 ++++- virtio-devices/src/vhost_user/mod.rs | 8 +++++--- virtio-devices/src/vhost_user/net.rs | 5 ++++- virtio-devices/src/vhost_user/vu_common_ctrl.rs | 4 +++- 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/virtio-devices/src/vhost_user/blk.rs b/virtio-devices/src/vhost_user/blk.rs index 8221b7b50..83653147b 100644 --- a/virtio-devices/src/vhost_user/blk.rs +++ b/virtio-devices/src/vhost_user/blk.rs @@ -254,7 +254,11 @@ impl VirtioDevice for Blk { .set_config(offset as u32, VhostUserConfigFlags::WRITABLE, data) .map_err(Error::VhostUserSetConfig) { - error!("Failed setting vhost-user-blk configuration: {e:?}"); + error!( + "Failed setting vhost-user-blk configuration for socket {} at offset 0x{offset:x} with length {}: {e:?}", + self.vu_common.socket_path, + data.len() + ); } } @@ -313,7 +317,10 @@ impl VirtioDevice for Blk { if let Some(vu) = &self.vu_common.vu && let Err(e) = vu.lock().unwrap().reset_vhost_user() { - error!("Failed to reset vhost-user daemon: {e:?}"); + error!( + "Failed to reset vhost-user daemon for socket {}: {e:?}", + self.vu_common.socket_path + ); return None; } diff --git a/virtio-devices/src/vhost_user/fs.rs b/virtio-devices/src/vhost_user/fs.rs index 967fdecf9..509a7a34f 100644 --- a/virtio-devices/src/vhost_user/fs.rs +++ b/virtio-devices/src/vhost_user/fs.rs @@ -294,7 +294,10 @@ impl VirtioDevice for Fs { if let Some(vu) = &self.vu_common.vu && let Err(e) = vu.lock().unwrap().reset_vhost_user() { - error!("Failed to reset vhost-user daemon: {e:?}"); + error!( + "Failed to reset vhost-user daemon for socket {}: {e:?}", + self.vu_common.socket_path + ); return None; } diff --git a/virtio-devices/src/vhost_user/generic_vhost_user.rs b/virtio-devices/src/vhost_user/generic_vhost_user.rs index 177883443..aed24b082 100644 --- a/virtio-devices/src/vhost_user/generic_vhost_user.rs +++ b/virtio-devices/src/vhost_user/generic_vhost_user.rs @@ -317,7 +317,10 @@ impl VirtioDevice for GenericVhostUser { if let Some(vu) = &self.vu_common.vu && let Err(e) = vu.lock().unwrap().reset_vhost_user() { - error!("Failed to reset vhost-user daemon: {e:?}"); + error!( + "Failed to reset vhost-user daemon for socket {}: {e:?}", + self.vu_common.socket_path + ); return None; } diff --git a/virtio-devices/src/vhost_user/mod.rs b/virtio-devices/src/vhost_user/mod.rs index 01a75f057..abca12c05 100644 --- a/virtio-devices/src/vhost_user/mod.rs +++ b/virtio-devices/src/vhost_user/mod.rs @@ -231,7 +231,8 @@ impl VhostUserEpollHandler { ) .map_err(|e| { EpollHelperError::IoError(std::io::Error::other(format!( - "failed connecting vhost-user backend {e:?}" + "failed connecting vhost-user backend for socket {}: {e:?}", + self.socket_path ))) })?; @@ -282,7 +283,8 @@ impl EpollHelperHandler for VhostUserEpollHandle HUP_CONNECTION_EVENT => { self.reconnect(helper).map_err(|e| { EpollHelperError::HandleEvent(anyhow!( - "failed to reconnect vhost-user backend: {e:?}" + "failed to reconnect vhost-user backend for socket {}: {e:?}", + self.socket_path )) })?; } @@ -370,7 +372,7 @@ impl VhostUserCommon { }; if self.vu.is_none() { - error!("Missing vhost-user handle"); + error!("Missing vhost-user handle for socket {}", self.socket_path); return Err(ActivateError::BadActivate); } let vu = self.vu.as_ref().unwrap(); diff --git a/virtio-devices/src/vhost_user/net.rs b/virtio-devices/src/vhost_user/net.rs index 1c85b5f38..4803ade33 100644 --- a/virtio-devices/src/vhost_user/net.rs +++ b/virtio-devices/src/vhost_user/net.rs @@ -374,7 +374,10 @@ impl VirtioDevice for Net { if let Some(vu) = &self.vu_common.vu && let Err(e) = vu.lock().unwrap().reset_vhost_user() { - error!("Failed to reset vhost-user daemon: {e:?}"); + error!( + "Failed to reset vhost-user daemon for socket {}: {e:?}", + self.vu_common.socket_path + ); return None; } diff --git a/virtio-devices/src/vhost_user/vu_common_ctrl.rs b/virtio-devices/src/vhost_user/vu_common_ctrl.rs index 23e06a3c0..5ad9425c5 100644 --- a/virtio-devices/src/vhost_user/vu_common_ctrl.rs +++ b/virtio-devices/src/vhost_user/vu_common_ctrl.rs @@ -428,7 +428,9 @@ impl VhostUserHandle { } }; - error!("Failed connecting the backend after trying for 1 minute: {err:?}"); + error!( + "Failed connecting the backend after trying for 1 minute for socket {socket_path}: {err:?}" + ); Err(Error::VhostUserConnect) } }