build: Upgrade vm-memory crates and its consumers

Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
Bo Chen 2023-11-07 11:37:23 -08:00 committed by Rob Bradford
parent d4a163dd39
commit 4d7a4c598a
25 changed files with 179 additions and 188 deletions

79
Cargo.lock generated
View File

@ -118,7 +118,7 @@ dependencies = [
"versionize",
"versionize_derive",
"vm-fdt",
"vm-memory 0.12.2",
"vm-memory",
"vm-migration",
"vmm-sys-util",
]
@ -339,7 +339,7 @@ dependencies = [
"versionize_derive",
"virtio-bindings",
"virtio-queue",
"vm-memory 0.12.2",
"vm-memory",
"vm-virtio",
"vmm-sys-util",
]
@ -447,7 +447,7 @@ dependencies = [
"thiserror",
"tpm",
"tracer",
"vm-memory 0.12.2",
"vm-memory",
"vmm",
"vmm-sys-util",
"wait-timeout",
@ -587,7 +587,7 @@ dependencies = [
"versionize_derive",
"vm-allocator",
"vm-device",
"vm-memory 0.12.2",
"vm-memory",
"vm-migration",
"vmm-sys-util",
]
@ -974,7 +974,7 @@ dependencies = [
"serde_with",
"thiserror",
"vfio-ioctls",
"vm-memory 0.12.2",
"vm-memory",
"vmm-sys-util",
]
@ -1155,11 +1155,11 @@ dependencies = [
[[package]]
name = "linux-loader"
version = "0.9.1"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1db6a725c8000971f83fa93ed7ee1b600e55a1471a2a653379d3c84f72effdcf"
checksum = "132a531b85b3a164012ab682c72f8f2cce7757f187be5f60782fd2b4cda9cb34"
dependencies = [
"vm-memory 0.12.2",
"vm-memory",
]
[[package]]
@ -1300,7 +1300,7 @@ dependencies = [
"versionize_derive",
"virtio-bindings",
"virtio-queue",
"vm-memory 0.12.2",
"vm-memory",
"vm-virtio",
"vmm-sys-util",
]
@ -1487,7 +1487,7 @@ dependencies = [
"vfio_user",
"vm-allocator",
"vm-device",
"vm-memory 0.12.2",
"vm-memory",
"vm-migration",
"vmm-sys-util",
]
@ -2305,14 +2305,14 @@ dependencies = [
"mshv-ioctls",
"thiserror",
"vfio-bindings",
"vm-memory 0.13.1",
"vm-memory",
"vmm-sys-util",
]
[[package]]
name = "vfio_user"
version = "0.1.0"
source = "git+https://github.com/rust-vmm/vfio-user?branch=main#2d96b90a7279547356ad8f83aaa3115ad5497302"
source = "git+https://github.com/rust-vmm/vfio-user?branch=main#6c72e997e61d9e84b8ee691ad63ece6c717cf5aa"
dependencies = [
"bitflags 1.3.2",
"libc",
@ -2322,34 +2322,34 @@ dependencies = [
"serde_json",
"thiserror",
"vfio-bindings",
"vm-memory 0.12.2",
"vm-memory",
"vmm-sys-util",
]
[[package]]
name = "vhost"
version = "0.8.1"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61957aeb36daf0b00b87fff9c10dd28a161bd35ab157553d340d183b3d8756e6"
checksum = "289adfce099c71f8310f895932ccd978f352ca494ea47496dbe20d4241888b82"
dependencies = [
"bitflags 1.3.2",
"bitflags 2.4.1",
"libc",
"vm-memory 0.12.2",
"vm-memory",
"vmm-sys-util",
]
[[package]]
name = "vhost-user-backend"
version = "0.10.1"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab069cdedaf18a0673766eb0a07a0f4ee3ed1b8e17fbfe4aafe5b988e2de1d01"
checksum = "61255322e3ebe93fb77d9f6d99577eca7089bbea4174076c5353a8024a463061"
dependencies = [
"libc",
"log",
"vhost",
"virtio-bindings",
"virtio-queue",
"vm-memory 0.12.2",
"vm-memory",
"vmm-sys-util",
]
@ -2368,7 +2368,7 @@ dependencies = [
"vhost-user-backend",
"virtio-bindings",
"virtio-queue",
"vm-memory 0.12.2",
"vm-memory",
"vmm-sys-util",
]
@ -2386,15 +2386,15 @@ dependencies = [
"vhost",
"vhost-user-backend",
"virtio-bindings",
"vm-memory 0.12.2",
"vm-memory",
"vmm-sys-util",
]
[[package]]
name = "virtio-bindings"
version = "0.2.1"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c18d7b74098a946470ea265b5bacbbf877abc3373021388454de0d47735a5b98"
checksum = "878bcb1b2812a10c30d53b0ed054999de3d98f25ece91fc173973f9c57aaae86"
[[package]]
name = "virtio-devices"
@ -2424,7 +2424,7 @@ dependencies = [
"virtio-queue",
"vm-allocator",
"vm-device",
"vm-memory 0.12.2",
"vm-memory",
"vm-migration",
"vm-virtio",
"vmm-sys-util",
@ -2432,13 +2432,13 @@ dependencies = [
[[package]]
name = "virtio-queue"
version = "0.9.0"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35aca00da06841bd99162c381ec65893cace23ca0fb89254302cfe4bec4c300f"
checksum = "73a01db2cfb6c4b9bc20608b1336263d16714ea8db05de9fec2a254e076f9385"
dependencies = [
"log",
"virtio-bindings",
"vm-memory 0.12.2",
"vm-memory",
"vmm-sys-util",
]
@ -2448,7 +2448,7 @@ version = "0.1.0"
dependencies = [
"arch",
"libc",
"vm-memory 0.12.2",
"vm-memory",
]
[[package]]
@ -2460,7 +2460,7 @@ dependencies = [
"serde",
"thiserror",
"vfio-ioctls",
"vm-memory 0.12.2",
"vm-memory",
"vmm-sys-util",
]
@ -2469,24 +2469,13 @@ name = "vm-fdt"
version = "0.2.0"
source = "git+https://github.com/rust-vmm/vm-fdt?branch=main#77212bd0d62913e445c89376bcbbecd595afc5b1"
[[package]]
name = "vm-memory"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dc276f0d00c17b9aeb584da0f1e1c673df0d183cc2539e3636ec8cbc5eae99b"
dependencies = [
"arc-swap",
"libc",
"thiserror",
"winapi",
]
[[package]]
name = "vm-memory"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5376c9ee5ebe2103a310d8241936cfb93c946734b0479a4fa5bdf7a64abbacd8"
dependencies = [
"arc-swap",
"libc",
"thiserror",
"winapi",
@ -2502,7 +2491,7 @@ dependencies = [
"thiserror",
"versionize",
"versionize_derive",
"vm-memory 0.12.2",
"vm-memory",
]
[[package]]
@ -2511,7 +2500,7 @@ version = "0.1.0"
dependencies = [
"log",
"virtio-queue",
"vm-memory 0.12.2",
"vm-memory",
]
[[package]]
@ -2559,7 +2548,7 @@ dependencies = [
"virtio-queue",
"vm-allocator",
"vm-device",
"vm-memory 0.12.2",
"vm-memory",
"vm-migration",
"vm-virtio",
"vmm-sys-util",

View File

@ -47,7 +47,7 @@ tpm = { path = "tpm"}
tracer = { path = "tracer" }
vmm = { path = "vmm" }
vmm-sys-util = "0.11.0"
vm-memory = "0.12.2"
vm-memory = "0.13.1"
zbus = { version = "3.11.1", optional = true }
# List of patched crates

View File

@ -14,14 +14,14 @@ anyhow = "1.0.75"
byteorder = "1.4.3"
hypervisor = { path = "../hypervisor" }
libc = "0.2.147"
linux-loader = { version = "0.9.1", features = ["elf", "bzimage", "pe"] }
linux-loader = { version = "0.10.0", features = ["elf", "bzimage", "pe"] }
log = "0.4.17"
serde = { version = "1.0.168", features = ["rc", "derive"] }
thiserror = "1.0.40"
uuid = "1.3.4"
versionize = "0.1.10"
versionize_derive = "0.1.4"
vm-memory = { version = "0.12.2", features = ["backend-mmap", "backend-bitmap"] }
vm-memory = { version = "0.13.1", features = ["backend-mmap", "backend-bitmap"] }
vm-migration = { path = "../vm-migration" }
vmm-sys-util = { version = "0.11.0", features = ["with-serde"] }

View File

@ -21,7 +21,7 @@ uuid = { version = "1.3.4", features = ["v4"] }
versionize = "0.1.10"
versionize_derive = "0.1.4"
virtio-bindings = { version = "0.2.0", features = ["virtio-v5_0_0"] }
virtio-queue = "0.9.0"
vm-memory = { version = "0.12.2", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
virtio-queue = "0.10.0"
vm-memory = { version = "0.13.1", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
vm-virtio = { path = "../vm-virtio" }
vmm-sys-util = "0.11.0"

View File

@ -21,7 +21,7 @@ versionize = "0.1.10"
versionize_derive = "0.1.4"
vm-allocator = { path = "../vm-allocator" }
vm-device = { path = "../vm-device" }
vm-memory = "0.12.2"
vm-memory = "0.13.1"
vm-migration = { path = "../vm-migration" }
vmm-sys-util = "0.11.0"

28
fuzz/Cargo.lock generated
View File

@ -507,9 +507,9 @@ dependencies = [
[[package]]
name = "linux-loader"
version = "0.9.1"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1db6a725c8000971f83fa93ed7ee1b600e55a1471a2a653379d3c84f72effdcf"
checksum = "132a531b85b3a164012ab682c72f8f2cce7757f187be5f60782fd2b4cda9cb34"
dependencies = [
"vm-memory",
]
@ -917,7 +917,7 @@ dependencies = [
[[package]]
name = "vfio-bindings"
version = "0.4.0"
source = "git+https://github.com/rust-vmm/vfio?branch=main#847b0aa504ac6367efe42ba7e96a2d050737d4f0"
source = "git+https://github.com/rust-vmm/vfio?branch=main#59c604fa6e42080f0a47c124ba29454fe4cb7475"
dependencies = [
"vmm-sys-util",
]
@ -925,7 +925,7 @@ dependencies = [
[[package]]
name = "vfio-ioctls"
version = "0.2.0"
source = "git+https://github.com/rust-vmm/vfio?branch=main#847b0aa504ac6367efe42ba7e96a2d050737d4f0"
source = "git+https://github.com/rust-vmm/vfio?branch=main#59c604fa6e42080f0a47c124ba29454fe4cb7475"
dependencies = [
"byteorder",
"kvm-bindings",
@ -941,7 +941,7 @@ dependencies = [
[[package]]
name = "vfio_user"
version = "0.1.0"
source = "git+https://github.com/rust-vmm/vfio-user?branch=main#2d96b90a7279547356ad8f83aaa3115ad5497302"
source = "git+https://github.com/rust-vmm/vfio-user?branch=main#6c72e997e61d9e84b8ee691ad63ece6c717cf5aa"
dependencies = [
"bitflags 1.3.2",
"libc",
@ -957,11 +957,11 @@ dependencies = [
[[package]]
name = "vhost"
version = "0.8.1"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61957aeb36daf0b00b87fff9c10dd28a161bd35ab157553d340d183b3d8756e6"
checksum = "289adfce099c71f8310f895932ccd978f352ca494ea47496dbe20d4241888b82"
dependencies = [
"bitflags 1.3.2",
"bitflags 2.4.1",
"libc",
"vm-memory",
"vmm-sys-util",
@ -969,9 +969,9 @@ dependencies = [
[[package]]
name = "virtio-bindings"
version = "0.2.1"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c18d7b74098a946470ea265b5bacbbf877abc3373021388454de0d47735a5b98"
checksum = "878bcb1b2812a10c30d53b0ed054999de3d98f25ece91fc173973f9c57aaae86"
[[package]]
name = "virtio-devices"
@ -1009,9 +1009,9 @@ dependencies = [
[[package]]
name = "virtio-queue"
version = "0.9.0"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35aca00da06841bd99162c381ec65893cace23ca0fb89254302cfe4bec4c300f"
checksum = "73a01db2cfb6c4b9bc20608b1336263d16714ea8db05de9fec2a254e076f9385"
dependencies = [
"log",
"virtio-bindings",
@ -1048,9 +1048,9 @@ source = "git+https://github.com/rust-vmm/vm-fdt?branch=main#c5a99ab71b130435927
[[package]]
name = "vm-memory"
version = "0.12.2"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dc276f0d00c17b9aeb584da0f1e1c673df0d183cc2539e3636ec8cbc5eae99b"
checksum = "5376c9ee5ebe2103a310d8241936cfb93c946734b0479a4fa5bdf7a64abbacd8"
dependencies = [
"arc-swap",
"libc",

View File

@ -14,16 +14,16 @@ devices = { path = "../devices" }
epoll = "4.3.1"
libc = "0.2.150"
libfuzzer-sys = "0.4.7"
linux-loader = { version = "0.9.1", features = ["elf", "bzimage", "pe"] }
linux-loader = { version = "0.10.0", features = ["elf", "bzimage", "pe"] }
micro_http = { git = "https://github.com/firecracker-microvm/micro-http", branch = "main" }
net_util = { path = "../net_util" }
once_cell = "1.18.0"
seccompiler = "0.4.0"
virtio-devices = { path = "../virtio-devices" }
virtio-queue = "0.9.0"
virtio-queue = "0.10.0"
vmm = { path = "../vmm" }
vmm-sys-util = "0.11.2"
vm-memory = "0.12.2"
vm-memory = "0.13.1"
vm-device = { path = "../vm-device" }
vm-virtio = { path = "../vm-virtio" }

View File

@ -25,7 +25,7 @@ mshv-ioctls = { git = "https://github.com/rust-vmm/mshv", branch = "main", optio
serde = { version = "1.0.168", features = ["rc", "derive"] }
serde_with = { version = "3.4.0", default-features = false, features = ["macros"] }
vfio-ioctls = { git = "https://github.com/rust-vmm/vfio", branch = "main", default-features = false }
vm-memory = { version = "0.12.2", features = ["backend-mmap", "backend-atomic"] }
vm-memory = { version = "0.13.1", features = ["backend-mmap", "backend-atomic"] }
vmm-sys-util = { version = "0.11.0", features = ["with-serde"] }
thiserror = "1.0.40"

View File

@ -16,8 +16,8 @@ thiserror = "1.0.40"
versionize = "0.1.10"
versionize_derive = "0.1.4"
virtio-bindings = "0.2.0"
virtio-queue = "0.9.0"
vm-memory = { version = "0.12.2", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
virtio-queue = "0.10.0"
vm-memory = { version = "0.13.1", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
vm-virtio = { path = "../vm-virtio" }
vmm-sys-util = "0.11.0"

View File

@ -26,5 +26,5 @@ versionize = "0.1.10"
versionize_derive = "0.1.4"
vm-allocator = { path = "../vm-allocator" }
vm-device = { path = "../vm-device" }
vm-memory = { version = "0.12.2", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
vm-memory = { version = "0.13.1", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
vm-migration = { path = "../vm-migration" }

View File

@ -13,10 +13,9 @@ epoll = "4.3.3"
libc = "0.2.147"
log = "0.4.17"
option_parser = { path = "../option_parser" }
vhost = { version = "0.8.1", features = ["vhost-user-slave"] }
vhost-user-backend = "0.10.1"
vhost = { version = "0.9.0", features = ["vhost-user-backend"] }
vhost-user-backend = "0.11.0"
virtio-bindings = "0.2.0"
virtio-queue = "0.9.0"
vm-memory = "0.12.2"
virtio-queue = "0.10.0"
vm-memory = "0.13.1"
vmm-sys-util = "0.11.0"

View File

@ -299,9 +299,10 @@ impl VhostUserBlkBackend {
}
}
impl VhostUserBackendMut<VringRwLock<GuestMemoryAtomic<GuestMemoryMmap>>, AtomicBitmap>
for VhostUserBlkBackend
{
impl VhostUserBackendMut for VhostUserBlkBackend {
type Bitmap = AtomicBitmap;
type Vring = VringRwLock<GuestMemoryAtomic<GuestMemoryMmap>>;
fn num_queues(&self) -> usize {
self.config.num_queues as usize
}
@ -350,7 +351,7 @@ impl VhostUserBackendMut<VringRwLock<GuestMemoryAtomic<GuestMemoryMmap>>, Atomic
evset: EventSet,
vrings: &[VringRwLock<GuestMemoryAtomic<GuestMemoryMmap>>],
thread_id: usize,
) -> VhostUserBackendResult<bool> {
) -> VhostUserBackendResult<()> {
if evset != EventSet::IN {
return Err(Error::HandleEventNotEpollIn.into());
}
@ -394,7 +395,7 @@ impl VhostUserBackendMut<VringRwLock<GuestMemoryAtomic<GuestMemoryMmap>>, Atomic
thread.process_queue(&mut vring);
}
Ok(false)
Ok(())
}
_ => Err(Error::HandleEventUnknownEvent.into()),
}

View File

@ -13,9 +13,9 @@ libc = "0.2.147"
log = "0.4.17"
net_util = { path = "../net_util" }
option_parser = { path = "../option_parser" }
vhost = { version = "0.8.1", features = ["vhost-user-slave"] }
vhost-user-backend = "0.10.1"
vhost = { version = "0.9.0", features = ["vhost-user-backend"] }
vhost-user-backend = "0.11.0"
virtio-bindings = "0.2.0"
vm-memory = "0.12.2"
vm-memory = "0.13.1"
vmm-sys-util = "0.11.0"

View File

@ -158,9 +158,10 @@ impl VhostUserNetBackend {
}
}
impl VhostUserBackendMut<VringRwLock<GuestMemoryAtomic<GuestMemoryMmap>>, AtomicBitmap>
for VhostUserNetBackend
{
impl VhostUserBackendMut for VhostUserNetBackend {
type Bitmap = AtomicBitmap;
type Vring = VringRwLock<GuestMemoryAtomic<GuestMemoryMmap>>;
fn num_queues(&self) -> usize {
self.num_queues
}
@ -203,7 +204,7 @@ impl VhostUserBackendMut<VringRwLock<GuestMemoryAtomic<GuestMemoryMmap>>, Atomic
_evset: EventSet,
vrings: &[VringRwLock<GuestMemoryAtomic<GuestMemoryMmap>>],
thread_id: usize,
) -> VhostUserBackendResult<bool> {
) -> VhostUserBackendResult<()> {
let mut thread = self.threads[thread_id].lock().unwrap();
match device_event {
0 => {
@ -245,7 +246,7 @@ impl VhostUserBackendMut<VringRwLock<GuestMemoryAtomic<GuestMemoryMmap>>, Atomic
_ => return Err(Error::HandleEventUnknownEvent.into()),
}
Ok(false)
Ok(())
}
fn exit_event(&self, thread_index: usize) -> Option<EventFd> {

View File

@ -27,12 +27,12 @@ serial_buffer = { path = "../serial_buffer" }
thiserror = "1.0.40"
versionize = "0.1.10"
versionize_derive = "0.1.4"
vhost = { version = "0.8.1", features = ["vhost-user-master", "vhost-user-slave", "vhost-kern", "vhost-vdpa"] }
vhost = { version = "0.9.0", features = ["vhost-user-frontend", "vhost-user-backend", "vhost-kern", "vhost-vdpa"] }
virtio-bindings = { version = "0.2.0", features = ["virtio-v5_0_0"] }
virtio-queue = "0.9.0"
virtio-queue = "0.10.0"
vm-allocator = { path = "../vm-allocator" }
vm-device = { path = "../vm-device" }
vm-memory = { version = "0.12.2", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
vm-memory = { version = "0.13.1", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
vm-migration = { path = "../vm-migration" }
vm-virtio = { path = "../vm-virtio" }
vmm-sys-util = "0.11.0"

View File

@ -23,7 +23,7 @@ use vhost::vhost_user::message::{
VhostUserConfigFlags, VhostUserProtocolFeatures, VhostUserVirtioFeatures,
VHOST_USER_CONFIG_OFFSET,
};
use vhost::vhost_user::{MasterReqHandler, VhostUserMaster, VhostUserMasterReqHandler};
use vhost::vhost_user::{FrontendReqHandler, VhostUserFrontend, VhostUserFrontendReqHandler};
use virtio_bindings::virtio_blk::{
VIRTIO_BLK_F_BLK_SIZE, VIRTIO_BLK_F_CONFIG_WCE, VIRTIO_BLK_F_DISCARD, VIRTIO_BLK_F_FLUSH,
VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_MQ, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_SEG_MAX,
@ -50,8 +50,8 @@ pub struct State {
impl VersionMapped for State {}
struct SlaveReqHandler {}
impl VhostUserMasterReqHandler for SlaveReqHandler {}
struct BackendReqHandler {}
impl VhostUserFrontendReqHandler for BackendReqHandler {}
pub struct Blk {
common: VirtioCommon,
@ -294,7 +294,7 @@ impl VirtioDevice for Blk {
self.common.activate(&queues, &interrupt_cb)?;
self.guest_memory = Some(mem.clone());
let slave_req_handler: Option<MasterReqHandler<SlaveReqHandler>> = None;
let backend_req_handler: Option<FrontendReqHandler<BackendReqHandler>> = None;
// Run a dedicated thread for handling potential reconnections with
// the backend.
@ -305,7 +305,7 @@ impl VirtioDevice for Blk {
queues,
interrupt_cb,
self.common.acked_features,
slave_req_handler,
backend_req_handler,
kill_evt,
pause_evt,
)?;

View File

@ -22,11 +22,11 @@ use std::thread;
use versionize::{VersionMap, Versionize, VersionizeResult};
use versionize_derive::Versionize;
use vhost::vhost_user::message::{
VhostUserFSSlaveMsg, VhostUserFSSlaveMsgFlags, VhostUserProtocolFeatures,
VhostUserVirtioFeatures, VHOST_USER_FS_SLAVE_ENTRIES,
VhostUserFSBackendMsg, VhostUserFSBackendMsgFlags, VhostUserProtocolFeatures,
VhostUserVirtioFeatures, VHOST_USER_FS_BACKEND_ENTRIES,
};
use vhost::vhost_user::{
HandlerResult, MasterReqHandler, VhostUserMaster, VhostUserMasterReqHandler,
FrontendReqHandler, HandlerResult, VhostUserFrontend, VhostUserFrontendReqHandler,
};
use virtio_queue::Queue;
use vm_memory::{
@ -48,19 +48,19 @@ pub struct State {
pub config: VirtioFsConfig,
pub acked_protocol_features: u64,
pub vu_num_queues: usize,
pub slave_req_support: bool,
pub backend_req_support: bool,
}
impl VersionMapped for State {}
struct SlaveReqHandler {
struct BackendReqHandler {
cache_offset: GuestAddress,
cache_size: u64,
mmap_cache_addr: u64,
mem: GuestMemoryAtomic<GuestMemoryMmap>,
}
impl SlaveReqHandler {
impl BackendReqHandler {
// Make sure request is within cache range
fn is_req_valid(&self, offset: u64, len: u64) -> bool {
let end = match offset.checked_add(len) {
@ -72,16 +72,16 @@ impl SlaveReqHandler {
}
}
impl VhostUserMasterReqHandler for SlaveReqHandler {
impl VhostUserFrontendReqHandler for BackendReqHandler {
fn handle_config_change(&self) -> HandlerResult<u64> {
debug!("handle_config_change");
Ok(0)
}
fn fs_slave_map(&self, fs: &VhostUserFSSlaveMsg, fd: &dyn AsRawFd) -> HandlerResult<u64> {
debug!("fs_slave_map");
fn fs_backend_map(&self, fs: &VhostUserFSBackendMsg, fd: &dyn AsRawFd) -> HandlerResult<u64> {
debug!("fs_backend_map");
for i in 0..VHOST_USER_FS_SLAVE_ENTRIES {
for i in 0..VHOST_USER_FS_BACKEND_ENTRIES {
let offset = fs.cache_offset[i];
let len = fs.len[i];
@ -115,10 +115,10 @@ impl VhostUserMasterReqHandler for SlaveReqHandler {
Ok(0)
}
fn fs_slave_unmap(&self, fs: &VhostUserFSSlaveMsg) -> HandlerResult<u64> {
debug!("fs_slave_unmap");
fn fs_backend_unmap(&self, fs: &VhostUserFSBackendMsg) -> HandlerResult<u64> {
debug!("fs_backend_unmap");
for i in 0..VHOST_USER_FS_SLAVE_ENTRIES {
for i in 0..VHOST_USER_FS_BACKEND_ENTRIES {
let mut len = fs.len[i];
// Ignore if the length is 0.
@ -126,7 +126,7 @@ impl VhostUserMasterReqHandler for SlaveReqHandler {
continue;
}
// Need to handle a special case where the slave ask for the unmapping
// Need to handle a special case where the backend ask for the unmapping
// of the entire mapping.
let offset = if len == 0xffff_ffff_ffff_ffff {
len = self.cache_size;
@ -159,10 +159,10 @@ impl VhostUserMasterReqHandler for SlaveReqHandler {
Ok(0)
}
fn fs_slave_sync(&self, fs: &VhostUserFSSlaveMsg) -> HandlerResult<u64> {
debug!("fs_slave_sync");
fn fs_backend_sync(&self, fs: &VhostUserFSBackendMsg) -> HandlerResult<u64> {
debug!("fs_backend_sync");
for i in 0..VHOST_USER_FS_SLAVE_ENTRIES {
for i in 0..VHOST_USER_FS_BACKEND_ENTRIES {
let offset = fs.cache_offset[i];
let len = fs.len[i];
@ -187,11 +187,11 @@ impl VhostUserMasterReqHandler for SlaveReqHandler {
Ok(0)
}
fn fs_slave_io(&self, fs: &VhostUserFSSlaveMsg, fd: &dyn AsRawFd) -> HandlerResult<u64> {
debug!("fs_slave_io");
fn fs_backend_io(&self, fs: &VhostUserFSBackendMsg, fd: &dyn AsRawFd) -> HandlerResult<u64> {
debug!("fs_backend_io");
let mut done: u64 = 0;
for i in 0..VHOST_USER_FS_SLAVE_ENTRIES {
for i in 0..VHOST_USER_FS_BACKEND_ENTRIES {
// Ignore if the length is 0.
if fs.len[i] == 0 {
continue;
@ -230,8 +230,8 @@ impl VhostUserMasterReqHandler for SlaveReqHandler {
};
while len > 0 {
let ret = if (fs.flags[i] & VhostUserFSSlaveMsgFlags::MAP_W)
== VhostUserFSSlaveMsgFlags::MAP_W
let ret = if (fs.flags[i] & VhostUserFSBackendMsgFlags::MAP_W)
== VhostUserFSBackendMsgFlags::MAP_W
{
debug!("write: foffset={}, len={}", foffset, len);
// SAFETY: FFI call with valid arguments
@ -298,7 +298,7 @@ pub struct Fs {
// Hold ownership of the memory that is allocated for the device
// which will be automatically dropped when the device is dropped
cache: Option<(VirtioSharedMemoryList, MmapRegion)>,
slave_req_support: bool,
backend_req_support: bool,
seccomp_action: SeccompAction,
guest_memory: Option<GuestMemoryAtomic<GuestMemoryMmap>>,
epoll_thread: Option<thread::JoinHandle<()>>,
@ -321,7 +321,7 @@ impl Fs {
iommu: bool,
state: Option<State>,
) -> Result<Fs> {
let mut slave_req_support = false;
let mut backend_req_support = false;
// Calculate the actual number of queues needed.
let num_queues = NUM_QUEUE_OFFSET + req_num_queues;
@ -335,7 +335,7 @@ impl Fs {
acked_protocol_features,
vu_num_queues,
config,
slave_req_support,
backend_req_support,
paused,
) = if let Some(state) = state {
info!("Restoring vhost-user-fs {}", id);
@ -351,7 +351,7 @@ impl Fs {
state.acked_protocol_features,
state.vu_num_queues,
state.config,
state.slave_req_support,
state.backend_req_support,
true,
)
} else {
@ -363,10 +363,10 @@ impl Fs {
| VhostUserProtocolFeatures::REPLY_ACK
| VhostUserProtocolFeatures::INFLIGHT_SHMFD
| VhostUserProtocolFeatures::LOG_SHMFD;
let slave_protocol_features =
VhostUserProtocolFeatures::SLAVE_REQ | VhostUserProtocolFeatures::SLAVE_SEND_FD;
let backend_protocol_features =
VhostUserProtocolFeatures::BACKEND_REQ | VhostUserProtocolFeatures::BACKEND_SEND_FD;
if cache.is_some() {
avail_protocol_features |= slave_protocol_features;
avail_protocol_features |= backend_protocol_features;
}
let (acked_features, acked_protocol_features) =
@ -389,10 +389,10 @@ impl Fs {
return Err(Error::BadQueueNum);
}
if acked_protocol_features & slave_protocol_features.bits()
== slave_protocol_features.bits()
if acked_protocol_features & backend_protocol_features.bits()
== backend_protocol_features.bits()
{
slave_req_support = true;
backend_req_support = true;
}
// Create virtio-fs device configuration.
@ -411,7 +411,7 @@ impl Fs {
acked_protocol_features,
num_queues,
config,
slave_req_support,
backend_req_support,
false,
)
};
@ -437,7 +437,7 @@ impl Fs {
id,
config,
cache,
slave_req_support,
backend_req_support,
seccomp_action,
guest_memory: None,
epoll_thread: None,
@ -453,7 +453,7 @@ impl Fs {
config: self.config,
acked_protocol_features: self.vu_common.acked_protocol_features,
vu_num_queues: self.vu_common.vu_num_queues,
slave_req_support: self.slave_req_support,
backend_req_support: self.backend_req_support,
}
}
}
@ -507,10 +507,10 @@ impl VirtioDevice for Fs {
self.common.activate(&queues, &interrupt_cb)?;
self.guest_memory = Some(mem.clone());
// Initialize slave communication.
let slave_req_handler = if self.slave_req_support {
// Initialize backend communication.
let backend_req_handler = if self.backend_req_support {
if let Some(cache) = self.cache.as_ref() {
let vu_master_req_handler = Arc::new(SlaveReqHandler {
let vu_frontend_req_handler = Arc::new(BackendReqHandler {
cache_offset: cache.0.addr,
cache_size: cache.0.len,
mmap_cache_addr: cache.0.host_addr,
@ -518,8 +518,8 @@ impl VirtioDevice for Fs {
});
let mut req_handler =
MasterReqHandler::new(vu_master_req_handler).map_err(|e| {
ActivateError::VhostUserFsSetup(Error::MasterReqHandlerCreation(e))
FrontendReqHandler::new(vu_frontend_req_handler).map_err(|e| {
ActivateError::VhostUserFsSetup(Error::FrontendReqHandlerCreation(e))
})?;
if self.vu_common.acked_protocol_features
@ -546,7 +546,7 @@ impl VirtioDevice for Fs {
queues,
interrupt_cb,
self.common.acked_features,
slave_req_handler,
backend_req_handler,
kill_evt,
pause_evt,
)?;

View File

@ -17,7 +17,7 @@ use versionize::Versionize;
use vhost::vhost_user::message::{
VhostUserInflight, VhostUserProtocolFeatures, VhostUserVirtioFeatures,
};
use vhost::vhost_user::{MasterReqHandler, VhostUserMasterReqHandler};
use vhost::vhost_user::{FrontendReqHandler, VhostUserFrontendReqHandler};
use vhost::Error as VhostError;
use virtio_queue::Error as QueueError;
use virtio_queue::Queue;
@ -61,8 +61,8 @@ pub enum Error {
MemoryRegions(MmapError),
#[error("Failed removing socket path: {0}")]
RemoveSocketPath(io::Error),
#[error("Failed to create master: {0}")]
VhostUserCreateMaster(VhostError),
#[error("Failed to create frontend: {0}")]
VhostUserCreateFrontend(VhostError),
#[error("Failed to open vhost device: {0}")]
VhostUserOpen(VhostError),
#[error("Connection to socket failed")]
@ -105,10 +105,10 @@ pub enum Error {
VhostIrqRead(io::Error),
#[error("Failed to read vhost eventfd: {0}")]
VhostUserMemoryRegion(MmapError),
#[error("Failed to create the master request handler from slave: {0}")]
MasterReqHandlerCreation(vhost::vhost_user::Error),
#[error("Set slave request fd failed: {0}")]
VhostUserSetSlaveRequestFd(vhost::Error),
#[error("Failed to create the frontend request handler from backend: {0}")]
FrontendReqHandlerCreation(vhost::vhost_user::Error),
#[error("Set backend request fd failed: {0}")]
VhostUserSetBackendRequestFd(vhost::Error),
#[error("Add memory region failed: {0}")]
VhostUserAddMemReg(VhostError),
#[error("Failed getting the configuration: {0}")]
@ -155,7 +155,7 @@ pub const DEFAULT_VIRTIO_FEATURES: u64 = 1 << VIRTIO_F_RING_INDIRECT_DESC
| VhostUserVirtioFeatures::PROTOCOL_FEATURES.bits();
const HUP_CONNECTION_EVENT: u16 = EPOLL_HELPER_EVENT_LAST + 1;
const SLAVE_REQ_EVENT: u16 = EPOLL_HELPER_EVENT_LAST + 2;
const BACKEND_REQ_EVENT: u16 = EPOLL_HELPER_EVENT_LAST + 2;
#[derive(Default)]
pub struct Inflight {
@ -163,7 +163,7 @@ pub struct Inflight {
pub fd: Option<std::fs::File>,
}
pub struct VhostUserEpollHandler<S: VhostUserMasterReqHandler> {
pub struct VhostUserEpollHandler<S: VhostUserFrontendReqHandler> {
pub vu: Arc<Mutex<VhostUserHandle>>,
pub mem: GuestMemoryAtomic<GuestMemoryMmap>,
pub kill_evt: EventFd,
@ -174,11 +174,11 @@ pub struct VhostUserEpollHandler<S: VhostUserMasterReqHandler> {
pub acked_protocol_features: u64,
pub socket_path: String,
pub server: bool,
pub slave_req_handler: Option<MasterReqHandler<S>>,
pub backend_req_handler: Option<FrontendReqHandler<S>>,
pub inflight: Option<Inflight>,
}
impl<S: VhostUserMasterReqHandler> VhostUserEpollHandler<S> {
impl<S: VhostUserFrontendReqHandler> VhostUserEpollHandler<S> {
pub fn run(
&mut self,
paused: Arc<AtomicBool>,
@ -191,8 +191,8 @@ impl<S: VhostUserMasterReqHandler> VhostUserEpollHandler<S> {
epoll::Events::EPOLLHUP,
)?;
if let Some(slave_req_handler) = &self.slave_req_handler {
helper.add_event(slave_req_handler.as_raw_fd(), SLAVE_REQ_EVENT)?;
if let Some(backend_req_handler) = &self.backend_req_handler {
helper.add_event(backend_req_handler.as_raw_fd(), BACKEND_REQ_EVENT)?;
}
helper.run(paused, paused_sync, self)?;
@ -231,7 +231,7 @@ impl<S: VhostUserMasterReqHandler> VhostUserEpollHandler<S> {
&self.virtio_interrupt,
self.acked_features,
self.acked_protocol_features,
&self.slave_req_handler,
&self.backend_req_handler,
self.inflight.as_mut(),
)
.map_err(|e| {
@ -255,7 +255,7 @@ impl<S: VhostUserMasterReqHandler> VhostUserEpollHandler<S> {
}
}
impl<S: VhostUserMasterReqHandler> EpollHelperHandler for VhostUserEpollHandler<S> {
impl<S: VhostUserFrontendReqHandler> EpollHelperHandler for VhostUserEpollHandler<S> {
fn handle_event(
&mut self,
helper: &mut EpollHelper,
@ -271,9 +271,9 @@ impl<S: VhostUserMasterReqHandler> EpollHelperHandler for VhostUserEpollHandler<
))
})?;
}
SLAVE_REQ_EVENT => {
if let Some(slave_req_handler) = self.slave_req_handler.as_mut() {
slave_req_handler.handle_request().map_err(|e| {
BACKEND_REQ_EVENT => {
if let Some(backend_req_handler) = self.backend_req_handler.as_mut() {
backend_req_handler.handle_request().map_err(|e| {
EpollHelperError::HandleEvent(anyhow!(
"Failed to handle request from vhost-user backend: {:?}",
e
@ -304,13 +304,13 @@ pub struct VhostUserCommon {
impl VhostUserCommon {
#[allow(clippy::too_many_arguments)]
pub fn activate<T: VhostUserMasterReqHandler>(
pub fn activate<T: VhostUserFrontendReqHandler>(
&mut self,
mem: GuestMemoryAtomic<GuestMemoryMmap>,
queues: Vec<(usize, Queue, EventFd)>,
interrupt_cb: Arc<dyn VirtioInterrupt>,
acked_features: u64,
slave_req_handler: Option<MasterReqHandler<T>>,
backend_req_handler: Option<FrontendReqHandler<T>>,
kill_evt: EventFd,
pause_evt: EventFd,
) -> std::result::Result<VhostUserEpollHandler<T>, ActivateError> {
@ -337,7 +337,7 @@ impl VhostUserCommon {
.collect(),
&interrupt_cb,
acked_features,
&slave_req_handler,
&backend_req_handler,
inflight.as_mut(),
)
.map_err(ActivateError::VhostUserSetup)?;
@ -353,7 +353,7 @@ impl VhostUserCommon {
acked_protocol_features: self.acked_protocol_features,
socket_path: self.socket_path.clone(),
server: self.server,
slave_req_handler,
backend_req_handler,
inflight,
})
}

View File

@ -20,7 +20,7 @@ use std::vec::Vec;
use versionize::{VersionMap, Versionize, VersionizeResult};
use versionize_derive::Versionize;
use vhost::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatures};
use vhost::vhost_user::{MasterReqHandler, VhostUserMaster, VhostUserMasterReqHandler};
use vhost::vhost_user::{FrontendReqHandler, VhostUserFrontend, VhostUserFrontendReqHandler};
use virtio_bindings::virtio_net::{
VIRTIO_NET_F_CSUM, VIRTIO_NET_F_CTRL_VQ, VIRTIO_NET_F_GUEST_CSUM, VIRTIO_NET_F_GUEST_ECN,
VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, VIRTIO_NET_F_GUEST_UFO,
@ -49,8 +49,8 @@ pub struct State {
impl VersionMapped for State {}
struct SlaveReqHandler {}
impl VhostUserMasterReqHandler for SlaveReqHandler {}
struct BackendReqHandler {}
impl VhostUserFrontendReqHandler for BackendReqHandler {}
pub struct Net {
common: VirtioCommon,
@ -342,7 +342,7 @@ impl VirtioDevice for Net {
self.ctrl_queue_epoll_thread = Some(epoll_threads.remove(0));
}
let slave_req_handler: Option<MasterReqHandler<SlaveReqHandler>> = None;
let backend_req_handler: Option<FrontendReqHandler<BackendReqHandler>> = None;
// The backend acknowledged features must not contain VIRTIO_NET_F_MAC
// since we don't expect the backend to handle it.
@ -357,7 +357,7 @@ impl VirtioDevice for Net {
queues,
interrupt_cb,
backend_acked_features,
slave_req_handler,
backend_req_handler,
kill_evt,
pause_evt,
)?;

View File

@ -20,7 +20,9 @@ use vhost::vhost_kern::vhost_binding::{VHOST_F_LOG_ALL, VHOST_VRING_F_LOG};
use vhost::vhost_user::message::{
VhostUserHeaderFlag, VhostUserInflight, VhostUserProtocolFeatures, VhostUserVirtioFeatures,
};
use vhost::vhost_user::{Master, MasterReqHandler, VhostUserMaster, VhostUserMasterReqHandler};
use vhost::vhost_user::{
Frontend, FrontendReqHandler, VhostUserFrontend, VhostUserFrontendReqHandler,
};
use vhost::{VhostBackend, VhostUserDirtyLogRegion, VhostUserMemoryRegionInfo, VringConfigData};
use virtio_queue::{Descriptor, Queue, QueueT};
use vm_memory::{
@ -47,7 +49,7 @@ struct VringInfo {
#[derive(Clone)]
pub struct VhostUserHandle {
vu: Master,
vu: Frontend,
ready: bool,
supports_migration: bool,
shm_log: Option<Arc<MmapRegion>>,
@ -148,13 +150,13 @@ impl VhostUserHandle {
}
#[allow(clippy::too_many_arguments)]
pub fn setup_vhost_user<S: VhostUserMasterReqHandler>(
pub fn setup_vhost_user<S: VhostUserFrontendReqHandler>(
&mut self,
mem: &GuestMemoryMmap,
queues: Vec<(usize, Queue, EventFd)>,
virtio_interrupt: &Arc<dyn VirtioInterrupt>,
acked_features: u64,
slave_req_handler: &Option<MasterReqHandler<S>>,
backend_req_handler: &Option<FrontendReqHandler<S>>,
inflight: Option<&mut Inflight>,
) -> Result<()> {
self.vu
@ -266,10 +268,10 @@ impl VhostUserHandle {
self.enable_vhost_user_vrings(self.queue_indexes.clone(), true)?;
if let Some(slave_req_handler) = slave_req_handler {
if let Some(backend_req_handler) = backend_req_handler {
self.vu
.set_slave_request_fd(&slave_req_handler.get_tx_raw_fd())
.map_err(Error::VhostUserSetSlaveRequestFd)?;
.set_backend_request_fd(&backend_req_handler.get_tx_raw_fd())
.map_err(Error::VhostUserSetBackendRequestFd)?;
}
self.vrings_info = Some(vrings_info);
@ -333,14 +335,14 @@ impl VhostUserHandle {
}
#[allow(clippy::too_many_arguments)]
pub fn reinitialize_vhost_user<S: VhostUserMasterReqHandler>(
pub fn reinitialize_vhost_user<S: VhostUserFrontendReqHandler>(
&mut self,
mem: &GuestMemoryMmap,
queues: Vec<(usize, Queue, EventFd)>,
virtio_interrupt: &Arc<dyn VirtioInterrupt>,
acked_features: u64,
acked_protocol_features: u64,
slave_req_handler: &Option<MasterReqHandler<S>>,
backend_req_handler: &Option<FrontendReqHandler<S>>,
inflight: Option<&mut Inflight>,
) -> Result<()> {
self.set_protocol_features_vhost_user(acked_features, acked_protocol_features)?;
@ -350,7 +352,7 @@ impl VhostUserHandle {
queues,
virtio_interrupt,
acked_features,
slave_req_handler,
backend_req_handler,
inflight,
)
}
@ -372,7 +374,7 @@ impl VhostUserHandle {
let (stream, _) = listener.accept().map_err(Error::AcceptConnection)?;
Ok(VhostUserHandle {
vu: Master::from_stream(stream, num_queues),
vu: Frontend::from_stream(stream, num_queues),
ready: false,
supports_migration: false,
shm_log: None,
@ -385,7 +387,7 @@ impl VhostUserHandle {
// Retry connecting for a full minute
let err = loop {
let err = match Master::connect(socket_path, num_queues) {
let err = match Frontend::connect(socket_path, num_queues) {
Ok(m) => {
return Ok(VhostUserHandle {
vu: m,
@ -414,7 +416,7 @@ impl VhostUserHandle {
}
}
pub fn socket_handle(&mut self) -> &mut Master {
pub fn socket_handle(&mut self) -> &mut Frontend {
&mut self.vu
}

View File

@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
libc = "0.2.147"
vm-memory = "0.12.2"
vm-memory = "0.13.1"
[target.'cfg(target_arch = "aarch64")'.dependencies]
arch = { path = "../arch" }

View File

@ -15,6 +15,5 @@ hypervisor = { path = "../hypervisor" }
thiserror = "1.0.40"
serde = { version = "1.0.168", features = ["rc", "derive"] }
vfio-ioctls = { git = "https://github.com/rust-vmm/vfio", branch = "main", default-features = false }
vm-memory = { version = "0.12.2", features = ["backend-mmap"] }
vm-memory = { version = "0.13.1", features = ["backend-mmap"] }
vmm-sys-util = "0.11.0"

View File

@ -11,4 +11,4 @@ serde = { version = "1.0.168", features = ["rc", "derive"] }
serde_json = "1.0.107"
versionize = "0.1.10"
versionize_derive = "0.1.4"
vm-memory = { version = "0.12.2", features = ["backend-mmap", "backend-atomic"] }
vm-memory = { version = "0.13.1", features = ["backend-mmap", "backend-atomic"] }

View File

@ -9,5 +9,5 @@ default = []
[dependencies]
log = "0.4.17"
virtio-queue = "0.9.0"
vm-memory = { version = "0.12.2", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
virtio-queue = "0.10.0"
vm-memory = { version = "0.13.1", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }

View File

@ -34,7 +34,7 @@ gdbstub = { version = "0.6.4", optional = true }
gdbstub_arch = { version = "0.2.4", optional = true }
hypervisor = { path = "../hypervisor" }
libc = "0.2.147"
linux-loader = { version = "0.9.1", features = ["elf", "bzimage", "pe"] }
linux-loader = { version = "0.10.0", features = ["elf", "bzimage", "pe"] }
log = "0.4.17"
micro_http = { git = "https://github.com/firecracker-microvm/micro-http", branch = "main" }
net_util = { path = "../net_util" }
@ -54,10 +54,10 @@ versionize_derive = "0.1.4"
vfio-ioctls = { git = "https://github.com/rust-vmm/vfio", branch = "main", default-features = false }
vfio_user = { git = "https://github.com/rust-vmm/vfio-user", branch = "main" }
virtio-devices = { path = "../virtio-devices" }
virtio-queue = "0.9.0"
virtio-queue = "0.10.0"
vm-allocator = { path = "../vm-allocator" }
vm-device = { path = "../vm-device" }
vm-memory = { version = "0.12.2", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
vm-memory = { version = "0.13.1", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
vm-migration = { path = "../vm-migration" }
vm-virtio = { path = "../vm-virtio" }
vmm-sys-util = { version = "0.11.0", features = ["with-serde"] }