Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ members = [
[workspace.dependencies]
virtio-bindings = "0.2.6"
virtio-queue = "0.17.0"
vm-memory = "=0.17.1"
vm-memory = "0.18.0"
vmm-sys-util = "0.15.0"

[patch.crates-io]
virtio-bindings = { git = "https://github.com/rust-vmm/vm-virtio.git" }
virtio-queue = { git = "https://github.com/rust-vmm/vm-virtio.git" }
2 changes: 2 additions & 0 deletions vhost-user-backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- [[#339]](https://github.com/rust-vmm/vhost/pull/339) Add support for `GET_SHMEM_CONFIG` message

### Changed
- [[#348]](https://github.com/rust-vmm/vhost/pull/348) Updated vm-memory to 0.18.0

### Deprecated
### Fixed

Expand Down
4 changes: 3 additions & 1 deletion vhost-user-backend/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ use vhost::vhost_user::{
use virtio_bindings::bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX;
use virtio_queue::{Error as VirtQueError, QueueT};
use vm_memory::mmap::NewBitmap;
use vm_memory::{GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryMmap, GuestRegionMmap};
use vm_memory::{
GuestAddress, GuestAddressSpace, GuestMemoryBackend, GuestMemoryMmap, GuestRegionMmap,
};
use vmm_sys_util::epoll::EventSet;

use super::backend::VhostUserBackend;
Expand Down
3 changes: 2 additions & 1 deletion vhost-user-backend/tests/vhost-user-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use vhost::vhost_user::{Backend, Frontend, Listener, VhostUserFrontend};
use vhost::{VhostBackend, VhostUserMemoryRegionInfo, VringConfigData};
use vhost_user_backend::{VhostUserBackendMut, VhostUserDaemon, VringRwLock};
use vm_memory::{
FileOffset, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic, GuestMemoryMmap,
FileOffset, GuestAddress, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryBackend,
GuestMemoryMmap,
};
use vmm_sys_util::epoll::EventSet;
use vmm_sys_util::event::{
Expand Down
2 changes: 2 additions & 0 deletions vhost/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- [[#339]](https://github.com/rust-vmm/vhost/pull/339) Add support for `GET_SHMEM_CONFIG` message

### Changed
- [[#348]](https://github.com/rust-vmm/vhost/pull/348) Updated vm-memory to 0.18.0

### Deprecated
### Fixed
- [[#338]](https://github.com/rust-vmm/vhost/pull/338) vhost: fix double-locking in Backend to Frontend request handlers
Expand Down
12 changes: 9 additions & 3 deletions vhost/src/vhost_kern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::os::unix::io::{AsRawFd, RawFd};

use libc::{c_void, ssize_t, write};

use vm_memory::{Address, GuestAddress, GuestAddressSpace, GuestMemory, GuestUsize};
use vm_memory::{Address, GuestAddress, GuestAddressSpace, GuestMemoryBackend, GuestUsize};
use vmm_sys_util::eventfd::EventFd;
use vmm_sys_util::ioctl::{ioctl, ioctl_with_mut_ref, ioctl_with_ptr, ioctl_with_ref};

Expand All @@ -36,6 +36,12 @@ pub mod vdpa;
#[cfg(feature = "vhost-vsock")]
pub mod vsock;

/// Helper trait to signify `GuestAddressSpace`s that are physical, which is required for
/// vhost_kern.
pub trait PhysicalGuestAddressSpace: GuestAddressSpace<M: GuestMemoryBackend> {}

impl<AS: GuestAddressSpace> PhysicalGuestAddressSpace for AS where AS::M: GuestMemoryBackend {}

#[inline]
fn ioctl_result<T>(rc: i32, res: T) -> Result<T> {
if rc < 0 {
Expand All @@ -57,7 +63,7 @@ fn io_result<T>(rc: isize, res: T) -> Result<T> {
/// Represent an in-kernel vhost device backend.
pub trait VhostKernBackend: AsRawFd {
/// Associated type to access guest memory.
type AS: GuestAddressSpace;
type AS: PhysicalGuestAddressSpace;

/// Get the object to access the guest's memory.
fn mem(&self) -> &Self::AS;
Expand Down Expand Up @@ -439,7 +445,7 @@ impl VhostIotlbMsgParser for vhost_msg_v2 {
impl VringConfigData {
/// Convert the config (guest address space) into vhost_vring_addr
/// (host address space).
pub fn to_vhost_vring_addr<AS: GuestAddressSpace>(
pub fn to_vhost_vring_addr<AS: PhysicalGuestAddressSpace>(
&self,
queue_index: usize,
mem: &AS,
Expand Down
7 changes: 4 additions & 3 deletions vhost/src/vhost_kern/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ use std::fs::{File, OpenOptions};
use std::os::unix::fs::OpenOptionsExt;
use std::os::unix::io::{AsRawFd, RawFd};

use vm_memory::GuestAddressSpace;
use vmm_sys_util::ioctl::ioctl_with_ref;

use super::vhost_binding::*;
use super::{ioctl_result, Error, Result, VhostKernBackend};
use super::{
ioctl_result, Error, PhysicalGuestAddressSpace as GuestAddressSpace, Result, VhostKernBackend,
};

use crate::net::*;

Expand Down Expand Up @@ -67,7 +68,7 @@ impl<AS: GuestAddressSpace> AsRawFd for Net<AS> {

#[cfg(test)]
mod tests {
use vm_memory::{GuestAddress, GuestMemory, GuestMemoryMmap};
use vm_memory::{GuestAddress, GuestMemoryBackend, GuestMemoryMmap};
use vmm_sys_util::eventfd::EventFd;

use super::*;
Expand Down
8 changes: 5 additions & 3 deletions vhost/src/vhost_kern/vdpa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ use std::os::raw::{c_uchar, c_uint};
use std::os::unix::fs::OpenOptionsExt;
use std::os::unix::io::{AsRawFd, RawFd};

use vm_memory::GuestAddressSpace;
use vmm_sys_util::eventfd::EventFd;
use vmm_sys_util::fam::*;
use vmm_sys_util::ioctl::{ioctl, ioctl_with_mut_ref, ioctl_with_ptr, ioctl_with_ref};

use super::vhost_binding::*;
use super::{ioctl_result, Error, Result, VhostKernBackend, VhostKernFeatures};
use super::{
ioctl_result, Error, PhysicalGuestAddressSpace as GuestAddressSpace, Result, VhostKernBackend,
VhostKernFeatures,
};
use crate::vdpa::*;
use crate::{VhostAccess, VhostIotlbBackend, VhostIotlbMsg, VhostIotlbType, VringConfigData};

Expand Down Expand Up @@ -347,7 +349,7 @@ mod tests {
const VHOST_VDPA_PATH: &str = "/dev/vhost-vdpa-0";

use std::alloc::{alloc, dealloc, Layout};
use vm_memory::{GuestAddress, GuestMemory, GuestMemoryMmap};
use vm_memory::{GuestAddress, GuestMemoryBackend, GuestMemoryMmap};
use vmm_sys_util::eventfd::EventFd;

use super::*;
Expand Down
7 changes: 4 additions & 3 deletions vhost/src/vhost_kern/vsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ use std::fs::{File, OpenOptions};
use std::os::unix::fs::OpenOptionsExt;
use std::os::unix::io::{AsRawFd, RawFd};

use vm_memory::GuestAddressSpace;
use vmm_sys_util::ioctl::ioctl_with_ref;

use super::vhost_binding::{VHOST_VSOCK_SET_GUEST_CID, VHOST_VSOCK_SET_RUNNING};
use super::{ioctl_result, Error, Result, VhostKernBackend};
use super::{
ioctl_result, Error, PhysicalGuestAddressSpace as GuestAddressSpace, Result, VhostKernBackend,
};
use crate::vsock::VhostVsock;

const VHOST_PATH: &str = "/dev/vhost-vsock";
Expand Down Expand Up @@ -83,7 +84,7 @@ impl<AS: GuestAddressSpace> AsRawFd for Vsock<AS> {

#[cfg(test)]
mod tests {
use vm_memory::{GuestAddress, GuestMemory, GuestMemoryMmap};
use vm_memory::{GuestAddress, GuestMemoryBackend, GuestMemoryMmap};
use vmm_sys_util::eventfd::EventFd;

use super::*;
Expand Down
2 changes: 2 additions & 0 deletions vhost/src/vhost_user/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,8 @@ mod tests {
msg.flags |= 0x80000000;
assert!(!msg.is_valid());
msg.flags &= !0x80000000;

assert!(msg.is_valid());
}

#[test]
Expand Down