From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Subject: [RFC PATCH 3/4] devices: vhost-user: Vring should be enabled after initialization
Date: Wed, 12 May 2021 17:08:11 +0000 [thread overview]
Message-ID: <20210512170812.192540-4-hi@alyssa.is> (raw)
In-Reply-To: <20210512170812.192540-1-hi@alyssa.is>
Based on cloud-hypervisor 97699a521fbdffd0166bc55be37c13bb6bc1949f.
> vm-virtio: vhost-user: Vring should be enabled after initialization
>
> As mentioned in the vhost-user specification, each ring is initialized
> in a stopped state. This means each ring should be enabled only after
> it has been correctly initialized.
---
devices/src/virtio/vhost_user/mod.rs | 2 --
devices/src/virtio/vhost_user/vu_common_ctrl.rs | 13 ++++---------
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/devices/src/virtio/vhost_user/mod.rs b/devices/src/virtio/vhost_user/mod.rs
index 99d8e651..43fc6350 100644
--- a/devices/src/virtio/vhost_user/mod.rs
+++ b/devices/src/virtio/vhost_user/mod.rs
@@ -70,8 +70,6 @@ pub enum Error {
VhostUserSetVringKick(VhostError),
/// Set vring enable failed.
VhostUserSetVringEnable(VhostError),
- /// Vhost-user setup vring failed.
- VhostUserSetupVringFailed,
/// Failed to create vhost eventfd.
VhostIrqCreate(std::io::Error),
/// Failed to read vhost eventfd.
diff --git a/devices/src/virtio/vhost_user/vu_common_ctrl.rs b/devices/src/virtio/vhost_user/vu_common_ctrl.rs
index 38b7b4f2..b594b177 100644
--- a/devices/src/virtio/vhost_user/vu_common_ctrl.rs
+++ b/devices/src/virtio/vhost_user/vu_common_ctrl.rs
@@ -87,6 +87,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)
@@ -99,17 +102,9 @@ pub fn setup_vhost_user(
queue_evts: Vec<EventFd>,
acked_features: u64,
) -> Result<Vec<(vmm_sys_util::eventfd::EventFd, Queue)>> {
- 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)
}
--
2.31.0
next prev parent reply other threads:[~2021-05-13 0:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-12 17:08 [RFC PATCH crosvm 0/4] Implement vhost-user-net Alyssa Ross
2021-05-12 17:08 ` [RFC PATCH 1/4] devices: port vhost-user-net from cloud-hypervisor Alyssa Ross
2021-05-12 17:08 ` [RFC PATCH 2/4] vhost_rs: vhost_user: Add missing protocol features Alyssa Ross
2021-05-12 17:08 ` Alyssa Ross [this message]
2021-05-12 17:08 ` [RFC PATCH 4/4] crosvm: use vhost-user-net instead of virtio-net Alyssa Ross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210512170812.192540-4-hi@alyssa.is \
--to=hi@alyssa.is \
--cc=devel@spectrum-os.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://spectrum-os.org/git/crosvm
https://spectrum-os.org/git/doc
https://spectrum-os.org/git/mktuntap
https://spectrum-os.org/git/nixpkgs
https://spectrum-os.org/git/spectrum
https://spectrum-os.org/git/ucspi-vsock
https://spectrum-os.org/git/www
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).