mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +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:
committed by
Sebastien Boeuf
parent
b443900cc2
commit
058946772a
@@ -15,6 +15,7 @@ use vhost::vhost_user::message::VhostUserVirtioFeatures;
|
|||||||
use vhost::vhost_user::Master;
|
use vhost::vhost_user::Master;
|
||||||
use vhost::Error as VhostError;
|
use vhost::Error as VhostError;
|
||||||
use vm_memory::{Error as MmapError, GuestAddressSpace, GuestMemoryAtomic};
|
use vm_memory::{Error as MmapError, GuestAddressSpace, GuestMemoryAtomic};
|
||||||
|
use vm_virtio::Error as VirtioError;
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
use vu_common_ctrl::{connect_vhost_user, reinitialize_vhost_user};
|
use vu_common_ctrl::{connect_vhost_user, reinitialize_vhost_user};
|
||||||
|
|
||||||
@@ -111,6 +112,8 @@ pub enum Error {
|
|||||||
MissingRegionFd,
|
MissingRegionFd,
|
||||||
/// Missing IrqFd
|
/// Missing IrqFd
|
||||||
MissingIrqFd,
|
MissingIrqFd,
|
||||||
|
/// Failed getting the available index.
|
||||||
|
GetAvailableIndex(VirtioError),
|
||||||
}
|
}
|
||||||
type Result<T> = std::result::Result<T, Error>;
|
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)
|
vu.set_vring_addr(queue_index, &config_data)
|
||||||
.map_err(Error::VhostUserSetVringAddr)?;
|
.map_err(Error::VhostUserSetVringAddr)?;
|
||||||
vu.set_vring_base(queue_index, 0u16)
|
vu.set_vring_base(
|
||||||
.map_err(Error::VhostUserSetVringBase)?;
|
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))
|
if let Some(eventfd) = virtio_interrupt.notifier(&VirtioInterruptType::Queue, Some(&queue))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user