From 1176552b6e5cbf5c131d6b26f0670271c6924b0f Mon Sep 17 00:00:00 2001 From: Dylan Reid Date: Thu, 7 May 2026 17:44:29 -0700 Subject: [PATCH] virtio-devices: vhost_user: refuse activate when disconnected If a guest observes DEVICE_NEEDS_RESET, resets the device, and tries to re-initialize it, but the VMM knows the backend is disconnected, we can short-circuit the doomed activation. This is not incorrect, but saves the VMM from making several round-trip calls to a peer process that doesn't exist. It'll also make the logs cleaner. Signed-off-by: Dylan Reid --- virtio-devices/src/vhost_user/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/virtio-devices/src/vhost_user/mod.rs b/virtio-devices/src/vhost_user/mod.rs index c5581a3f8..babc823ae 100644 --- a/virtio-devices/src/vhost_user/mod.rs +++ b/virtio-devices/src/vhost_user/mod.rs @@ -480,6 +480,14 @@ impl VhostUserCommon { kill_evt: EventFd, pause_evt: EventFd, ) -> std::result::Result, ActivateError> { + if self.disconnected.load(Ordering::Relaxed) { + warn!( + "Not activating disconnected vhost-user device for socket {}", + self.socket_path + ); + return Err(ActivateError::BadActivate); + } + let mut inflight: Option = if self.acked_protocol_features & VhostUserProtocolFeatures::INFLIGHT_SHMFD.bits() != 0 {