From a6364115228261d2016a3f5dffcc76994ad95f93 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Mon, 9 Aug 2021 12:04:01 +0200 Subject: [PATCH] vitio-devices: vhost_user: Factorize some part of the initialization Introducing a new function to factorize a small part of the initialization that is shared between a full reinitialization and a restoration. Signed-off-by: Sebastien Boeuf --- .../src/vhost_user/vu_common_ctrl.rs | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/virtio-devices/src/vhost_user/vu_common_ctrl.rs b/virtio-devices/src/vhost_user/vu_common_ctrl.rs index 4acd8a98d..5aa7dfdec 100644 --- a/virtio-devices/src/vhost_user/vu_common_ctrl.rs +++ b/virtio-devices/src/vhost_user/vu_common_ctrl.rs @@ -284,17 +284,10 @@ impl VhostUserHandle { self.vu.reset_owner().map_err(Error::VhostUserResetOwner) } - #[allow(clippy::too_many_arguments)] - pub fn reinitialize_vhost_user( + pub fn set_protocol_features_vhost_user( &mut self, - mem: &GuestMemoryMmap, - queues: Vec, - queue_evts: Vec, - virtio_interrupt: &Arc, acked_features: u64, acked_protocol_features: u64, - slave_req_handler: &Option>, - inflight: Option<&mut Inflight>, ) -> Result<()> { self.vu.set_owner().map_err(Error::VhostUserSetOwner)?; self.vu @@ -317,6 +310,23 @@ impl VhostUserHandle { self.update_supports_migration(acked_features, acked_protocol_features); + Ok(()) + } + + #[allow(clippy::too_many_arguments)] + pub fn reinitialize_vhost_user( + &mut self, + mem: &GuestMemoryMmap, + queues: Vec, + queue_evts: Vec, + virtio_interrupt: &Arc, + acked_features: u64, + acked_protocol_features: u64, + slave_req_handler: &Option>, + inflight: Option<&mut Inflight>, + ) -> Result<()> { + self.set_protocol_features_vhost_user(acked_features, acked_protocol_features)?; + self.setup_vhost_user( mem, queues,