mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: vhost_user: net: Handle reconnection
This commit implements the reconnection feature for vhost-user-net in case the connection with the backend is shutdown. The guest has no knowledge about what happens when a disconnection occurs, which simplifies the code to handle the reconnection. The reconnection happens with the backend, and the VMM goes through the vhost-user setup once again. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -173,3 +173,34 @@ pub fn reset_vhost_user(vu: &mut Master, num_queues: usize) -> Result<()> {
|
||||
// Reset the owner.
|
||||
vu.reset_owner().map_err(Error::VhostUserResetOwner)
|
||||
}
|
||||
|
||||
pub fn reinitialize_vhost_user(
|
||||
vu: &mut Master,
|
||||
mem: &GuestMemoryMmap,
|
||||
queues: Vec<Queue>,
|
||||
queue_evts: Vec<EventFd>,
|
||||
virtio_interrupt: &Arc<dyn VirtioInterrupt>,
|
||||
acked_features: u64,
|
||||
acked_protocol_features: u64,
|
||||
) -> Result<()> {
|
||||
vu.set_owner().map_err(Error::VhostUserSetOwner)?;
|
||||
vu.get_features().map_err(Error::VhostUserGetFeatures)?;
|
||||
|
||||
if acked_features & VhostUserVirtioFeatures::PROTOCOL_FEATURES.bits() != 0 {
|
||||
if let Some(acked_protocol_features) =
|
||||
VhostUserProtocolFeatures::from_bits(acked_protocol_features)
|
||||
{
|
||||
vu.set_protocol_features(acked_protocol_features)
|
||||
.map_err(Error::VhostUserSetProtocolFeatures)?;
|
||||
}
|
||||
}
|
||||
|
||||
setup_vhost_user(
|
||||
vu,
|
||||
mem,
|
||||
queues,
|
||||
queue_evts,
|
||||
virtio_interrupt,
|
||||
acked_features,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user