diff --git a/vhost-user-backend/src/handler.rs b/vhost-user-backend/src/handler.rs index 5d52edc..0d855e7 100644 --- a/vhost-user-backend/src/handler.rs +++ b/vhost-user-backend/src/handler.rs @@ -30,7 +30,10 @@ use super::event_loop::{VringEpollError, VringEpollResult}; use super::vring::VringT; use super::GM; -const MAX_MEM_SLOTS: u64 = 32; +// vhost in the kernel usually supports 509 mem slots. +// The 509 used to be the KVM limit, it supported 512, but 3 were used +// for internal purposes (nowadays, it supports more than that). +const MAX_MEM_SLOTS: u64 = 509; #[derive(Debug)] /// Errors related to vhost-user handler. diff --git a/vhost-user-backend/tests/vhost-user-server.rs b/vhost-user-backend/tests/vhost-user-server.rs index d3e6bb7..d8be86d 100644 --- a/vhost-user-backend/tests/vhost-user-server.rs +++ b/vhost-user-backend/tests/vhost-user-server.rs @@ -211,7 +211,7 @@ fn vhost_user_client(path: &Path, barrier: Arc) { let state = frontend.get_vring_base(0).unwrap(); frontend.set_vring_base(0, state as u16).unwrap(); - assert_eq!(frontend.get_max_mem_slots().unwrap(), 32); + assert_eq!(frontend.get_max_mem_slots().unwrap(), 509); let region = VhostUserMemoryRegionInfo::new(0x800000, 0x100000, addr, 0, fd.file().as_raw_fd()); frontend.add_mem_region(®ion).unwrap(); frontend.remove_mem_region(®ion).unwrap(); diff --git a/vhost/src/vhost_user/dummy_backend.rs b/vhost/src/vhost_user/dummy_backend.rs index 060a344..9d9f977 100644 --- a/vhost/src/vhost_user/dummy_backend.rs +++ b/vhost/src/vhost_user/dummy_backend.rs @@ -8,7 +8,7 @@ use super::*; pub const MAX_QUEUE_NUM: usize = 2; pub const MAX_VRING_NUM: usize = 256; -pub const MAX_MEM_SLOTS: usize = 32; +pub const MAX_MEM_SLOTS: usize = 509; pub const VIRTIO_FEATURES: u64 = 0x40000003; #[derive(Default)] diff --git a/vhost/src/vhost_user/mod.rs b/vhost/src/vhost_user/mod.rs index c7aed41..66f8c10 100644 --- a/vhost/src/vhost_user/mod.rs +++ b/vhost/src/vhost_user/mod.rs @@ -490,7 +490,7 @@ mod tests { frontend.set_vring_err(0, &eventfd).unwrap(); let max_mem_slots = frontend.get_max_mem_slots().unwrap(); - assert_eq!(max_mem_slots, 32); + assert_eq!(max_mem_slots, 509); let region_file: File = TempFile::new().unwrap().into_file(); let region =