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 <sboeuf@meta.com>
Assisted-by: Claude:claude-opus-4-8
This commit is contained in:
Sebastien Boeuf
2026-07-23 01:43:25 -07:00
parent 17b5deeaed
commit 7c190413ad

View File

@@ -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<Option<File>> {
// This device completes requests synchronously and keeps no inflight
// state.
Ok(None)
}
fn check_device_state(&self) -> VhostUserBackendResult<()> {
Ok(())
}
}
struct VhostUserBlkBackendConfig {