diff --git a/vm-virtio/src/vhost_user/mod.rs b/vm-virtio/src/vhost_user/mod.rs index 6c5271843..b458a2b91 100644 --- a/vm-virtio/src/vhost_user/mod.rs +++ b/vm-virtio/src/vhost_user/mod.rs @@ -77,8 +77,6 @@ pub enum Error { VhostUserSetVringKick(VhostError), /// Set vring enable failed. VhostUserSetVringEnable(VhostError), - /// Vhost-user setup vring failed. - VhostUserSetupVringFailed, /// Failed to create vhost eventfd. VhostIrqCreate(io::Error), /// Failed to read vhost eventfd. diff --git a/vm-virtio/src/vhost_user/vu_common_ctrl.rs b/vm-virtio/src/vhost_user/vu_common_ctrl.rs index 4c63df774..6ce0b124f 100644 --- a/vm-virtio/src/vhost_user/vu_common_ctrl.rs +++ b/vm-virtio/src/vhost_user/vu_common_ctrl.rs @@ -85,6 +85,9 @@ pub fn setup_vhost_user_vring( vu.set_vring_kick(queue_index, &queue_evts[queue_index]) .map_err(Error::VhostUserSetVringKick)?; + + vu.set_vring_enable(queue_index, true) + .map_err(Error::VhostUserSetVringEnable)?; } Ok(vu_interrupt_list) @@ -97,17 +100,9 @@ pub fn setup_vhost_user( queue_evts: Vec, acked_features: u64, ) -> Result> { - for i in 0..queues.len() { - vu.set_vring_enable(i, true) - .map_err(Error::VhostUserSetVringEnable)?; - } - let backend_features = vu.get_features().unwrap(); vu.set_features(acked_features & backend_features) .map_err(Error::VhostUserSetFeatures)?; - match setup_vhost_user_vring(vu, mem, queues, queue_evts) { - Ok(vu_interrupt_list) => Ok(vu_interrupt_list), - Err(_) => Err(Error::VhostUserSetupVringFailed), - } + setup_vhost_user_vring(vu, mem, queues, queue_evts) }