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 <dgreid@fb.com>
This commit is contained in:
Dylan Reid
2026-05-07 17:44:29 -07:00
committed by Bo Chen
parent 99ec20ff97
commit 1176552b6e

View File

@@ -480,6 +480,14 @@ impl VhostUserCommon {
kill_evt: EventFd,
pause_evt: EventFd,
) -> std::result::Result<VhostUserEpollHandler<T>, 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<Inflight> =
if self.acked_protocol_features & VhostUserProtocolFeatures::INFLIGHT_SHMFD.bits() != 0
{