virtio-devices: vhost_user: Enable snapshot/restore for vhost-user-*

Enable the DEVICE_STATE protocol feature negotiation for all vhost-user
devices (block, fs, net, and generic). Restoring the state (including
the backend state if present) and vrings.

Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
Rob Bradford
2026-03-26 14:22:42 -07:00
parent 2fbb98e2c3
commit cd3334a3c2
4 changed files with 86 additions and 54 deletions

View File

@@ -82,6 +82,7 @@ impl Net {
vu_num_queues,
config,
paused,
vring_bases,
) = if let Some(state) = state {
info!("Restoring vhost-user-net {id}");
@@ -95,6 +96,8 @@ impl Net {
state.acked_protocol_features,
)?;
vu.restore_state(&state)?;
// If the control queue feature has been negotiated, let's
// increase the number of queues.
if state.acked_features & (1 << VIRTIO_NET_F_CTRL_VQ) != 0 {
@@ -108,6 +111,7 @@ impl Net {
state.vu_num_queues,
state.config,
true,
state.vring_bases,
)
} else {
// Filling device and vring features VMM supports.
@@ -144,7 +148,8 @@ impl Net {
| VhostUserProtocolFeatures::CONFIGURE_MEM_SLOTS
| VhostUserProtocolFeatures::REPLY_ACK
| VhostUserProtocolFeatures::INFLIGHT_SHMFD
| VhostUserProtocolFeatures::LOG_SHMFD;
| VhostUserProtocolFeatures::LOG_SHMFD
| VhostUserProtocolFeatures::DEVICE_STATE;
let (mut acked_features, acked_protocol_features) =
vu.negotiate_features_vhost_user(avail_features, avail_protocol_features)?;
@@ -187,6 +192,7 @@ impl Net {
vu_num_queues,
config,
false,
None,
)
};
@@ -208,6 +214,7 @@ impl Net {
socket_path: vu_cfg.socket,
vu_num_queues,
server,
vring_bases,
..Default::default()
},
config,