virtio-devices: vhost_user: Set proper avail index to vhost-user backend

We should try to read the last avail index from the vring memory aera. This
is necessary when handling vhost-user socket reconnection.

Signed-off-by: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com>
This commit is contained in:
Jiachen Zhang
2021-06-03 12:10:03 +08:00
committed by Sebastien Boeuf
parent b443900cc2
commit 058946772a
2 changed files with 10 additions and 2 deletions

View File

@@ -143,8 +143,13 @@ pub fn setup_vhost_user(
vu.set_vring_addr(queue_index, &config_data)
.map_err(Error::VhostUserSetVringAddr)?;
vu.set_vring_base(queue_index, 0u16)
.map_err(Error::VhostUserSetVringBase)?;
vu.set_vring_base(
queue_index,
queue
.avail_index_from_memory(mem)
.map_err(Error::GetAvailableIndex)?,
)
.map_err(Error::VhostUserSetVringBase)?;
if let Some(eventfd) = virtio_interrupt.notifier(&VirtioInterruptType::Queue, Some(&queue))
{