From 7c190413ade04d6cebfc380291fea8842573cc2e Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Thu, 23 Jul 2026 01:43:25 -0700 Subject: [PATCH] vhost_user_block: Add DEVICE_STATE support Advertise VHOST_USER_PROTOCOL_F_DEVICE_STATE and implement the associated callbacks for the vhost-user-block backend. Given there's no specific state that needs to be saved through these operations, this a blank implementation. This support will be useful for testing the snapshot case where the source VM is preserved after the snapshot is complete. Signed-off-by: Sebastien Boeuf Assisted-by: Claude:claude-opus-4-8 --- vhost_user_block/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/vhost_user_block/src/lib.rs b/vhost_user_block/src/lib.rs index eb120a296..acf943dac 100644 --- a/vhost_user_block/src/lib.rs +++ b/vhost_user_block/src/lib.rs @@ -337,6 +337,7 @@ impl VhostUserBackendMut for VhostUserBlkBackend { VhostUserProtocolFeatures::CONFIG | VhostUserProtocolFeatures::MQ | VhostUserProtocolFeatures::CONFIGURE_MEM_SLOTS + | VhostUserProtocolFeatures::DEVICE_STATE } fn set_event_idx(&mut self, enabled: bool) { @@ -452,6 +453,21 @@ impl VhostUserBackendMut for VhostUserBlkBackend { ) -> VhostUserBackendResult<()> { Ok(()) } + + fn set_device_state_fd( + &mut self, + _direction: VhostTransferStateDirection, + _phase: VhostTransferStatePhase, + _file: File, + ) -> VhostUserBackendResult> { + // This device completes requests synchronously and keeps no inflight + // state. + Ok(None) + } + + fn check_device_state(&self) -> VhostUserBackendResult<()> { + Ok(()) + } } struct VhostUserBlkBackendConfig {