mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 03:12:27 +00:00
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:
parent
b443900cc2
commit
058946772a
@ -15,6 +15,7 @@ use vhost::vhost_user::message::VhostUserVirtioFeatures;
|
||||
use vhost::vhost_user::Master;
|
||||
use vhost::Error as VhostError;
|
||||
use vm_memory::{Error as MmapError, GuestAddressSpace, GuestMemoryAtomic};
|
||||
use vm_virtio::Error as VirtioError;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
use vu_common_ctrl::{connect_vhost_user, reinitialize_vhost_user};
|
||||
|
||||
@ -111,6 +112,8 @@ pub enum Error {
|
||||
MissingRegionFd,
|
||||
/// Missing IrqFd
|
||||
MissingIrqFd,
|
||||
/// Failed getting the available index.
|
||||
GetAvailableIndex(VirtioError),
|
||||
}
|
||||
type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
|
@ -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))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user