misc: Upgrade to use the vm-memory crate w/ dirty-page-tracking

As the first step to complete live-migration with tracking dirty-pages
written by the VMM, this commit patches the dependent vm-memory crate to
the upstream version with the dirty-page-tracking capability. Most
changes are due to the updated `GuestMemoryMmap`, `GuestRegionMmap`, and
`MmapRegion` structs which are taking an additional generic type
parameter to specify what 'bitmap backend' is used.

The above changes should be transparent to the rest of the code base,
e.g. all unit/integration tests should pass without additional changes.

Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
Bo Chen 2021-06-02 12:08:04 -07:00 committed by Rob Bradford
parent c7b794a7c5
commit b5bcdbaf48
53 changed files with 120 additions and 71 deletions

3
Cargo.lock generated
View File

@ -1228,8 +1228,7 @@ source = "git+https://github.com/rust-vmm/vm-fdt?branch=master#956b5a5ea1d7b9202
[[package]] [[package]]
name = "vm-memory" name = "vm-memory"
version = "0.5.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/rust-vmm/vm-memory?rev=5bd7138758183a73ac0da27ce40c004d95f1a7e9#5bd7138758183a73ac0da27ce40c004d95f1a7e9"
checksum = "625f401b1b8b3ac3d43f53903cd138cfe840bd985f8581e553027b31d2bb8ae8"
dependencies = [ dependencies = [
"arc-swap", "arc-swap",
"libc", "libc",

View File

@ -37,6 +37,7 @@ clap = { version = "2.33.3", features = ["wrap_help"] }
[patch.crates-io] [patch.crates-io]
kvm-bindings = { git = "https://github.com/cloud-hypervisor/kvm-bindings", branch = "ch-v0.4.0", features = ["with-serde", "fam-wrappers"] } kvm-bindings = { git = "https://github.com/cloud-hypervisor/kvm-bindings", branch = "ch-v0.4.0", features = ["with-serde", "fam-wrappers"] }
versionize_derive = { git = "https://github.com/cloud-hypervisor/versionize_derive", branch = "ch" } versionize_derive = { git = "https://github.com/cloud-hypervisor/versionize_derive", branch = "ch" }
vm-memory = { git = "https://github.com/rust-vmm/vm-memory", rev = "5bd7138758183a73ac0da27ce40c004d95f1a7e9"}
[dev-dependencies] [dev-dependencies]
credibility = "0.1.3" credibility = "0.1.3"

View File

@ -22,6 +22,6 @@ thiserror = "1.0"
versionize = "0.1.6" versionize = "0.1.6"
versionize_derive = "0.1.4" versionize_derive = "0.1.4"
vm-fdt = { git = "https://github.com/rust-vmm/vm-fdt", branch = "master" } vm-fdt = { git = "https://github.com/rust-vmm/vm-fdt", branch = "master" }
vm-memory = { version = "0.5.0", features = ["backend-mmap"] } vm-memory = { version = "0.5.0", features = ["backend-mmap", "backend-bitmap"] }
vm-migration = { path = "../vm-migration" } vm-migration = { path = "../vm-migration" }

View File

@ -12,6 +12,7 @@ use std::fmt::Debug;
use std::result; use std::result;
use super::super::DeviceType; use super::super::DeviceType;
use super::super::GuestMemoryMmap;
use super::super::InitramfsConfig; use super::super::InitramfsConfig;
use super::get_fdt_addr; use super::get_fdt_addr;
use super::gic::GicDevice; use super::gic::GicDevice;
@ -20,7 +21,7 @@ use super::layout::{
PCI_MMCONFIG_START, PCI_MMCONFIG_START,
}; };
use vm_fdt::{FdtWriter, FdtWriterResult}; use vm_fdt::{FdtWriter, FdtWriterResult};
use vm_memory::{Address, Bytes, GuestAddress, GuestMemory, GuestMemoryError, GuestMemoryMmap}; use vm_memory::{Address, Bytes, GuestAddress, GuestMemory, GuestMemoryError};
// This is a value for uniquely identifying the FDT node declaring the interrupt controller. // This is a value for uniquely identifying the FDT node declaring the interrupt controller.
const GIC_PHANDLE: u32 = 1; const GIC_PHANDLE: u32 = 1;

View File

@ -13,6 +13,7 @@ pub mod regs;
pub use self::fdt::DeviceInfoForFdt; pub use self::fdt::DeviceInfoForFdt;
use crate::DeviceType; use crate::DeviceType;
use crate::GuestMemoryMmap;
use crate::RegionType; use crate::RegionType;
use gic::GicDevice; use gic::GicDevice;
use std::collections::HashMap; use std::collections::HashMap;
@ -20,8 +21,7 @@ use std::ffi::CStr;
use std::fmt::Debug; use std::fmt::Debug;
use std::sync::Arc; use std::sync::Arc;
use vm_memory::{ use vm_memory::{
Address, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic, GuestMemoryMmap, Address, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic, GuestUsize,
GuestUsize,
}; };
/// Errors thrown while configuring aarch64 system. /// Errors thrown while configuring aarch64 system.

View File

@ -6,13 +6,13 @@
// found in the THIRD-PARTY file. // found in the THIRD-PARTY file.
use super::get_fdt_addr; use super::get_fdt_addr;
use crate::GuestMemoryMmap;
use hypervisor::kvm::kvm_bindings::{ use hypervisor::kvm::kvm_bindings::{
kvm_regs, user_pt_regs, KVM_REG_ARM64, KVM_REG_ARM_CORE, KVM_REG_SIZE_U64, kvm_regs, user_pt_regs, KVM_REG_ARM64, KVM_REG_ARM_CORE, KVM_REG_SIZE_U64,
}; };
use hypervisor::{arm64_core_reg_id, offset__of}; use hypervisor::{arm64_core_reg_id, offset__of};
use std::sync::Arc; use std::sync::Arc;
use std::{mem, result}; use std::{mem, result};
use vm_memory::GuestMemoryMmap;
/// Errors thrown while setting aarch64 registers. /// Errors thrown while setting aarch64 registers.
#[derive(Debug)] #[derive(Debug)]

View File

@ -14,6 +14,8 @@ extern crate log;
use std::fmt; use std::fmt;
use std::result; use std::result;
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<vm_memory::bitmap::AtomicBitmap>;
/// Type for returning error code. /// Type for returning error code.
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {

View File

@ -12,6 +12,7 @@ pub mod layout;
mod mpspec; mod mpspec;
mod mptable; mod mptable;
pub mod regs; pub mod regs;
use crate::GuestMemoryMmap;
use crate::InitramfsConfig; use crate::InitramfsConfig;
use crate::RegionType; use crate::RegionType;
use hypervisor::{CpuId, CpuIdEntry, CPUID_FLAG_VALID_INDEX}; use hypervisor::{CpuId, CpuIdEntry, CPUID_FLAG_VALID_INDEX};
@ -22,7 +23,7 @@ use linux_loader::loader::elf::start_info::{
use std::mem; use std::mem;
use vm_memory::{ use vm_memory::{
Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic, Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic,
GuestMemoryMmap, GuestMemoryRegion, GuestUsize, GuestMemoryRegion, GuestUsize,
}; };
mod smbios; mod smbios;
use std::arch::x86_64; use std::arch::x86_64;

View File

@ -7,14 +7,13 @@
use crate::layout::{APIC_START, HIGH_RAM_START, IOAPIC_START}; use crate::layout::{APIC_START, HIGH_RAM_START, IOAPIC_START};
use crate::x86_64::mpspec; use crate::x86_64::mpspec;
use crate::GuestMemoryMmap;
use libc::c_char; use libc::c_char;
use std::io; use std::io;
use std::mem; use std::mem;
use std::result; use std::result;
use std::slice; use std::slice;
use vm_memory::{ use vm_memory::{Address, ByteValued, Bytes, GuestAddress, GuestMemory, GuestMemoryError};
Address, ByteValued, Bytes, GuestAddress, GuestMemory, GuestMemoryError, GuestMemoryMmap,
};
// This is a workaround to the Rust enforcement specifying that any implementation of a foreign // This is a workaround to the Rust enforcement specifying that any implementation of a foreign
// trait (in this case `ByteValued`) where: // trait (in this case `ByteValued`) where:

View File

@ -7,12 +7,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-BSD-3-Clause file. // found in the LICENSE-BSD-3-Clause file.
use crate::layout::{BOOT_GDT_START, BOOT_IDT_START, PVH_INFO_START}; use crate::layout::{BOOT_GDT_START, BOOT_IDT_START, PVH_INFO_START};
use crate::GuestMemoryMmap;
use hypervisor::arch::x86::gdt::{gdt_entry, segment_from_gdt}; use hypervisor::arch::x86::gdt::{gdt_entry, segment_from_gdt};
use hypervisor::arch::x86::regs::*; use hypervisor::arch::x86::regs::*;
use hypervisor::x86_64::{FpuState, SpecialRegisters, StandardRegisters}; use hypervisor::x86_64::{FpuState, SpecialRegisters, StandardRegisters};
use std::sync::Arc; use std::sync::Arc;
use std::{mem, result}; use std::{mem, result};
use vm_memory::{Address, Bytes, GuestMemory, GuestMemoryError, GuestMemoryMmap}; use vm_memory::{Address, Bytes, GuestMemory, GuestMemoryError};
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
@ -163,7 +164,8 @@ pub fn configure_segments_and_sregs(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use vm_memory::{GuestAddress, GuestMemoryMmap}; use crate::GuestMemoryMmap;
use vm_memory::GuestAddress;
fn create_guest_mem() -> GuestMemoryMmap { fn create_guest_mem() -> GuestMemoryMmap {
GuestMemoryMmap::from_ranges(&[(GuestAddress(0), 0x10000)]).unwrap() GuestMemoryMmap::from_ranges(&[(GuestAddress(0), 0x10000)]).unwrap()

View File

@ -7,12 +7,13 @@
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use crate::layout::SMBIOS_START; use crate::layout::SMBIOS_START;
use crate::GuestMemoryMmap;
use std::fmt::{self, Display}; use std::fmt::{self, Display};
use std::mem; use std::mem;
use std::result; use std::result;
use std::slice; use std::slice;
use vm_memory::ByteValued; use vm_memory::ByteValued;
use vm_memory::{Address, Bytes, GuestAddress, GuestMemoryMmap}; use vm_memory::{Address, Bytes, GuestAddress};
#[allow(unused_variables)] #[allow(unused_variables)]
#[derive(Debug)] #[derive(Debug)]

View File

@ -1,10 +1,11 @@
// Copyright © 2021 Intel Corporation // Copyright © 2021 Intel Corporation
// //
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::GuestMemoryMmap;
use std::fs::File; use std::fs::File;
use std::io::{Read, Seek, SeekFrom}; use std::io::{Read, Seek, SeekFrom};
use thiserror::Error; use thiserror::Error;
use vm_memory::{ByteValued, Bytes, GuestAddress, GuestMemoryError, GuestMemoryMmap}; use vm_memory::{ByteValued, Bytes, GuestAddress, GuestMemoryError};
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum TdvfError { pub enum TdvfError {

View File

@ -17,7 +17,7 @@ thiserror = "1.0"
versionize = "0.1.6" versionize = "0.1.6"
versionize_derive = "0.1.4" versionize_derive = "0.1.4"
virtio-bindings = { version = "0.1", features = ["virtio-v5_0_0"]} virtio-bindings = { version = "0.1", features = ["virtio-v5_0_0"]}
vm-memory = { version = "0.5.0", features = ["backend-mmap", "backend-atomic"] } vm-memory = { version = "0.5.0", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
vm-virtio = { path = "../vm-virtio" } vm-virtio = { path = "../vm-virtio" }
vmm-sys-util = ">=0.3.1" vmm-sys-util = ">=0.3.1"

View File

@ -35,10 +35,14 @@ use std::sync::{Arc, Mutex};
use versionize::{VersionMap, Versionize, VersionizeResult}; use versionize::{VersionMap, Versionize, VersionizeResult};
use versionize_derive::Versionize; use versionize_derive::Versionize;
use virtio_bindings::bindings::virtio_blk::*; use virtio_bindings::bindings::virtio_blk::*;
use vm_memory::{ByteValued, Bytes, GuestAddress, GuestMemory, GuestMemoryError, GuestMemoryMmap}; use vm_memory::{
bitmap::AtomicBitmap, ByteValued, Bytes, GuestAddress, GuestMemory, GuestMemoryError,
};
use vm_virtio::DescriptorChain; use vm_virtio::DescriptorChain;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;
const SECTOR_SHIFT: u8 = 9; const SECTOR_SHIFT: u8 = 9;
pub const SECTOR_SIZE: u64 = 0x01 << SECTOR_SHIFT; pub const SECTOR_SIZE: u64 = 0x01 << SECTOR_SHIFT;

View File

@ -14,7 +14,7 @@ serde = "1.0.126"
versionize = "0.1.6" versionize = "0.1.6"
versionize_derive = "0.1.4" versionize_derive = "0.1.4"
virtio-bindings = "0.1.0" virtio-bindings = "0.1.0"
vm-memory = { version = "0.5.0", features = ["backend-mmap", "backend-atomic"] } vm-memory = { version = "0.5.0", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
vm-virtio = { path = "../vm-virtio" } vm-virtio = { path = "../vm-virtio" }
vmm-sys-util = ">=0.3.1" vmm-sys-util = ">=0.3.1"

View File

@ -2,6 +2,7 @@
// //
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use crate::GuestMemoryMmap;
use crate::Tap; use crate::Tap;
use libc::c_uint; use libc::c_uint;
use virtio_bindings::bindings::virtio_net::{ use virtio_bindings::bindings::virtio_net::{
@ -11,7 +12,7 @@ use virtio_bindings::bindings::virtio_net::{
VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
VIRTIO_NET_F_GUEST_UFO, VIRTIO_NET_OK, VIRTIO_NET_F_GUEST_UFO, VIRTIO_NET_OK,
}; };
use vm_memory::{ByteValued, Bytes, GuestMemoryError, GuestMemoryMmap}; use vm_memory::{ByteValued, Bytes, GuestMemoryError};
use vm_virtio::Queue; use vm_virtio::Queue;
#[derive(Debug)] #[derive(Debug)]

View File

@ -30,7 +30,9 @@ use virtio_bindings::bindings::virtio_net::{
VIRTIO_NET_F_GUEST_CSUM, VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_TSO4, 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, VIRTIO_NET_F_MAC, VIRTIO_NET_F_MQ, VIRTIO_NET_F_GUEST_TSO6, VIRTIO_NET_F_GUEST_UFO, VIRTIO_NET_F_MAC, VIRTIO_NET_F_MQ,
}; };
use vm_memory::ByteValued; use vm_memory::{bitmap::AtomicBitmap, ByteValued};
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;
pub use ctrl_queue::{CtrlQueue, Error as CtrlQueueError}; pub use ctrl_queue::{CtrlQueue, Error as CtrlQueueError};
pub use mac::{MacAddr, MAC_ADDR_LEN}; pub use mac::{MacAddr, MAC_ADDR_LEN};

View File

@ -3,13 +3,14 @@
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use super::{unregister_listener, vnet_hdr_len, Tap}; use super::{unregister_listener, vnet_hdr_len, Tap};
use crate::GuestMemoryMmap;
use rate_limiter::{RateLimiter, TokenType}; use rate_limiter::{RateLimiter, TokenType};
use std::io; use std::io;
use std::num::Wrapping; use std::num::Wrapping;
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc; use std::sync::Arc;
use vm_memory::{Bytes, GuestAddressSpace, GuestMemory, GuestMemoryAtomic, GuestMemoryMmap}; use vm_memory::{Bytes, GuestAddressSpace, GuestMemory, GuestMemoryAtomic};
use vm_virtio::Queue; use vm_virtio::Queue;
#[derive(Clone)] #[derive(Clone)]

View File

@ -12,7 +12,7 @@ epoll = ">=4.0.1"
libc = "0.2.95" libc = "0.2.95"
log = "0.4.14" log = "0.4.14"
virtio-bindings = "0.1.0" virtio-bindings = "0.1.0"
vm-memory = "0.5.0" vm-memory = { version = "0.5.0", features = ["backend-bitmap"] }
vm-virtio = { path = "../vm-virtio" } vm-virtio = { path = "../vm-virtio" }
vmm-sys-util = ">=0.3.1" vmm-sys-util = ">=0.3.1"
vhost = { git = "https://github.com/rust-vmm/vhost", branch = "master", package = "vhost", features = ["vhost-user-slave"] } vhost = { git = "https://github.com/rust-vmm/vhost", branch = "master", package = "vhost", features = ["vhost-user-slave"] }

View File

@ -27,10 +27,13 @@ use vhost::vhost_user::{
}; };
use virtio_bindings::bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX; use virtio_bindings::bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX;
use vm_memory::guest_memory::FileOffset; use vm_memory::guest_memory::FileOffset;
use vm_memory::{GuestAddress, GuestMemoryMmap, GuestRegionMmap, MmapRegion}; use vm_memory::{bitmap::AtomicBitmap, GuestAddress, MmapRegion};
use vm_virtio::Queue; use vm_virtio::Queue;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
pub type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;
pub type GuestRegionMmap = vm_memory::GuestRegionMmap<AtomicBitmap>;
const MAX_MEM_SLOTS: u64 = 32; const MAX_MEM_SLOTS: u64 = 32;
#[derive(Debug)] #[derive(Debug)]

View File

@ -30,11 +30,11 @@ use std::vec::Vec;
use std::{convert, error, fmt, io}; use std::{convert, error, fmt, io};
use vhost::vhost_user::message::*; use vhost::vhost_user::message::*;
use vhost::vhost_user::Listener; use vhost::vhost_user::Listener;
use vhost_user_backend::{VhostUserBackend, VhostUserDaemon, Vring}; use vhost_user_backend::{GuestMemoryMmap, VhostUserBackend, VhostUserDaemon, Vring};
use virtio_bindings::bindings::virtio_blk::*; use virtio_bindings::bindings::virtio_blk::*;
use virtio_bindings::bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX; use virtio_bindings::bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX;
use vm_memory::ByteValued; use vm_memory::ByteValued;
use vm_memory::{Bytes, GuestMemoryMmap}; use vm_memory::Bytes;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
const SECTOR_SHIFT: u8 = 9; const SECTOR_SHIFT: u8 = 9;

View File

@ -22,10 +22,10 @@ use std::sync::{Arc, Mutex, RwLock};
use std::vec::Vec; use std::vec::Vec;
use vhost::vhost_user::message::*; use vhost::vhost_user::message::*;
use vhost::vhost_user::Listener; use vhost::vhost_user::Listener;
use vhost_user_backend::{VhostUserBackend, VhostUserDaemon, Vring, VringWorker}; use vhost_user_backend::{GuestMemoryMmap, VhostUserBackend, VhostUserDaemon, Vring, VringWorker};
use virtio_bindings::bindings::virtio_net::*; use virtio_bindings::bindings::virtio_net::*;
use virtio_bindings::bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX; use virtio_bindings::bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX;
use vm_memory::{GuestMemoryAtomic, GuestMemoryMmap}; use vm_memory::GuestMemoryAtomic;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
pub type Result<T> = std::result::Result<T, Error>; pub type Result<T> = std::result::Result<T, Error>;

View File

@ -32,7 +32,7 @@ vhost = { git = "https://github.com/rust-vmm/vhost", branch = "master", package
virtio-bindings = { version = "0.1", features = ["virtio-v5_0_0"]} virtio-bindings = { version = "0.1", features = ["virtio-v5_0_0"]}
vm-allocator = { path = "../vm-allocator" } vm-allocator = { path = "../vm-allocator" }
vm-device = { path = "../vm-device" } vm-device = { path = "../vm-device" }
vm-memory = { version = "0.5.0", features = ["backend-mmap", "backend-atomic"] } vm-memory = { version = "0.5.0", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
vm-migration = { path = "../vm-migration" } vm-migration = { path = "../vm-migration" }
vm-virtio = { path = "../vm-virtio" } vm-virtio = { path = "../vm-virtio" }
vmm-sys-util = ">=0.3.1" vmm-sys-util = ">=0.3.1"

View File

@ -17,6 +17,7 @@ use super::{
VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1, VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1,
}; };
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
use crate::GuestMemoryMmap;
use crate::{VirtioInterrupt, VirtioInterruptType}; use crate::{VirtioInterrupt, VirtioInterruptType};
use libc::EFD_NONBLOCK; use libc::EFD_NONBLOCK;
use seccomp::{SeccompAction, SeccompFilter}; use seccomp::{SeccompAction, SeccompFilter};
@ -31,7 +32,7 @@ use std::thread;
use vm_memory::GuestMemory; use vm_memory::GuestMemory;
use vm_memory::{ use vm_memory::{
Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic, Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic,
GuestMemoryError, GuestMemoryMmap, GuestMemoryError,
}; };
use vm_migration::{Migratable, MigratableError, Pausable, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;

View File

@ -15,6 +15,7 @@ use super::{
EPOLL_HELPER_EVENT_LAST, EPOLL_HELPER_EVENT_LAST,
}; };
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
use crate::GuestMemoryMmap;
use crate::VirtioInterrupt; use crate::VirtioInterrupt;
use block_util::{ use block_util::{
async_io::AsyncIo, async_io::AsyncIoError, async_io::DiskFile, build_disk_image_id, Request, async_io::AsyncIo, async_io::AsyncIoError, async_io::DiskFile, build_disk_image_id, Request,
@ -34,7 +35,7 @@ use std::{collections::HashMap, convert::TryInto};
use versionize::{VersionMap, Versionize, VersionizeResult}; use versionize::{VersionMap, Versionize, VersionizeResult};
use versionize_derive::Versionize; use versionize_derive::Versionize;
use virtio_bindings::bindings::virtio_blk::*; use virtio_bindings::bindings::virtio_blk::*;
use vm_memory::{ByteValued, Bytes, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryMmap}; use vm_memory::{ByteValued, Bytes, GuestAddressSpace, GuestMemoryAtomic};
use vm_migration::VersionMapped; use vm_migration::VersionMapped;
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;

View File

@ -8,6 +8,7 @@ use super::{
VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1,
}; };
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
use crate::GuestMemoryMmap;
use crate::VirtioInterrupt; use crate::VirtioInterrupt;
use libc::EFD_NONBLOCK; use libc::EFD_NONBLOCK;
use seccomp::{SeccompAction, SeccompFilter}; use seccomp::{SeccompAction, SeccompFilter};
@ -23,7 +24,7 @@ use std::sync::{Arc, Barrier, Mutex};
use std::thread; use std::thread;
use versionize::{VersionMap, Versionize, VersionizeResult}; use versionize::{VersionMap, Versionize, VersionizeResult};
use versionize_derive::Versionize; use versionize_derive::Versionize;
use vm_memory::{ByteValued, Bytes, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryMmap}; use vm_memory::{ByteValued, Bytes, GuestAddressSpace, GuestMemoryAtomic};
use vm_migration::VersionMapped; use vm_migration::VersionMapped;
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;

View File

@ -7,6 +7,7 @@
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use crate::{ActivateError, ActivateResult, Error, Queue}; use crate::{ActivateError, ActivateResult, Error, Queue};
use crate::{GuestMemoryMmap, GuestRegionMmap};
use libc::EFD_NONBLOCK; use libc::EFD_NONBLOCK;
use std::collections::HashMap; use std::collections::HashMap;
use std::io::Write; use std::io::Write;
@ -16,7 +17,7 @@ use std::sync::{
Arc, Barrier, Arc, Barrier,
}; };
use std::thread; use std::thread;
use vm_memory::{GuestAddress, GuestMemoryAtomic, GuestMemoryMmap, GuestRegionMmap, GuestUsize}; use vm_memory::{GuestAddress, GuestMemoryAtomic, GuestUsize};
use vm_migration::{MigratableError, Pausable}; use vm_migration::{MigratableError, Pausable};
use vm_virtio::VirtioDeviceType; use vm_virtio::VirtioDeviceType;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;

View File

@ -9,6 +9,7 @@ use super::{
EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1,
}; };
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
use crate::GuestMemoryMmap;
use crate::{DmaRemapping, VirtioInterrupt, VirtioInterruptType}; use crate::{DmaRemapping, VirtioInterrupt, VirtioInterruptType};
use seccomp::{SeccompAction, SeccompFilter}; use seccomp::{SeccompAction, SeccompFilter};
use std::collections::BTreeMap; use std::collections::BTreeMap;
@ -26,7 +27,7 @@ use versionize_derive::Versionize;
use vm_device::dma_mapping::ExternalDmaMapping; use vm_device::dma_mapping::ExternalDmaMapping;
use vm_memory::{ use vm_memory::{
Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic, Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic,
GuestMemoryError, GuestMemoryMmap, GuestMemoryError,
}; };
use vm_migration::VersionMapped; use vm_migration::VersionMapped;
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};

View File

@ -49,9 +49,13 @@ pub use self::pmem::*;
pub use self::rng::*; pub use self::rng::*;
pub use self::vsock::*; pub use self::vsock::*;
pub use self::watchdog::*; pub use self::watchdog::*;
use vm_memory::{GuestAddress, GuestMemory}; use vm_memory::{bitmap::AtomicBitmap, GuestAddress, GuestMemory};
use vm_virtio::{queue::*, VirtioDeviceType}; use vm_virtio::{queue::*, VirtioDeviceType};
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;
type GuestRegionMmap = vm_memory::GuestRegionMmap<AtomicBitmap>;
type MmapRegion = vm_memory::MmapRegion<AtomicBitmap>;
const DEVICE_INIT: u32 = 0x00; const DEVICE_INIT: u32 = 0x00;
const DEVICE_ACKNOWLEDGE: u32 = 0x01; const DEVICE_ACKNOWLEDGE: u32 = 0x01;
const DEVICE_DRIVER: u32 = 0x02; const DEVICE_DRIVER: u32 = 0x02;

View File

@ -19,6 +19,7 @@ use super::{
EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1,
}; };
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
use crate::{GuestMemoryMmap, GuestRegionMmap};
use crate::{VirtioInterrupt, VirtioInterruptType}; use crate::{VirtioInterrupt, VirtioInterruptType};
use anyhow::anyhow; use anyhow::anyhow;
use libc::EFD_NONBLOCK; use libc::EFD_NONBLOCK;
@ -35,7 +36,7 @@ use std::thread;
use vm_device::dma_mapping::ExternalDmaMapping; use vm_device::dma_mapping::ExternalDmaMapping;
use vm_memory::{ use vm_memory::{
Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic, Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic,
GuestMemoryError, GuestMemoryMmap, GuestMemoryRegion, GuestRegionMmap, GuestMemoryError, GuestMemoryRegion,
}; };
use vm_migration::{Migratable, MigratableError, Pausable, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;

View File

@ -12,6 +12,7 @@ use super::{
EPOLL_HELPER_EVENT_LAST, EPOLL_HELPER_EVENT_LAST,
}; };
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
use crate::GuestMemoryMmap;
use crate::VirtioInterrupt; use crate::VirtioInterrupt;
use net_util::CtrlQueue; use net_util::CtrlQueue;
use net_util::{ use net_util::{
@ -33,7 +34,7 @@ use versionize::{VersionMap, Versionize, VersionizeResult};
use versionize_derive::Versionize; use versionize_derive::Versionize;
use virtio_bindings::bindings::virtio_net::*; use virtio_bindings::bindings::virtio_net::*;
use virtio_bindings::bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX; use virtio_bindings::bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX;
use vm_memory::{ByteValued, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryMmap}; use vm_memory::{ByteValued, GuestAddressSpace, GuestMemoryAtomic};
use vm_migration::VersionMapped; use vm_migration::VersionMapped;
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;

View File

@ -13,6 +13,7 @@ use super::{
EPOLL_HELPER_EVENT_LAST, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1,
}; };
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
use crate::{GuestMemoryMmap, MmapRegion};
use crate::{VirtioInterrupt, VirtioInterruptType}; use crate::{VirtioInterrupt, VirtioInterruptType};
use seccomp::{SeccompAction, SeccompFilter}; use seccomp::{SeccompAction, SeccompFilter};
use std::fmt::{self, Display}; use std::fmt::{self, Display};
@ -28,7 +29,7 @@ use versionize::{VersionMap, Versionize, VersionizeResult};
use versionize_derive::Versionize; use versionize_derive::Versionize;
use vm_memory::{ use vm_memory::{
Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic, Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic,
GuestMemoryError, GuestMemoryMmap, MmapRegion, GuestMemoryError,
}; };
use vm_migration::VersionMapped; use vm_migration::VersionMapped;
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};

View File

@ -9,6 +9,7 @@ use super::{
VIRTIO_F_VERSION_1, VIRTIO_F_VERSION_1,
}; };
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
use crate::GuestMemoryMmap;
use crate::{VirtioInterrupt, VirtioInterruptType}; use crate::{VirtioInterrupt, VirtioInterruptType};
use seccomp::{SeccompAction, SeccompFilter}; use seccomp::{SeccompAction, SeccompFilter};
use std::fs::File; use std::fs::File;
@ -20,7 +21,7 @@ use std::sync::{Arc, Barrier};
use std::thread; use std::thread;
use versionize::{VersionMap, Versionize, VersionizeResult}; use versionize::{VersionMap, Versionize, VersionizeResult};
use versionize_derive::Versionize; use versionize_derive::Versionize;
use vm_memory::{Bytes, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryMmap}; use vm_memory::{Bytes, GuestAddressSpace, GuestMemoryAtomic};
use vm_migration::VersionMapped; use vm_migration::VersionMapped;
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;

View File

@ -305,9 +305,10 @@ impl Snapshottable for VirtioPciCommonConfig {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::GuestMemoryMmap;
use crate::{ActivateResult, VirtioInterrupt}; use crate::{ActivateResult, VirtioInterrupt};
use std::sync::Arc; use std::sync::Arc;
use vm_memory::{GuestMemoryAtomic, GuestMemoryMmap}; use vm_memory::GuestMemoryAtomic;
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
struct DummyDevice(u32); struct DummyDevice(u32);

View File

@ -8,6 +8,7 @@
use super::VirtioPciCommonConfig; use super::VirtioPciCommonConfig;
use crate::transport::VirtioTransport; use crate::transport::VirtioTransport;
use crate::GuestMemoryMmap;
use crate::{ use crate::{
ActivateResult, Queue, VirtioDevice, VirtioDeviceType, VirtioInterrupt, VirtioInterruptType, ActivateResult, Queue, VirtioDevice, VirtioDeviceType, VirtioInterrupt, VirtioInterruptType,
DEVICE_ACKNOWLEDGE, DEVICE_DRIVER, DEVICE_DRIVER_OK, DEVICE_FAILED, DEVICE_FEATURES_OK, DEVICE_ACKNOWLEDGE, DEVICE_DRIVER, DEVICE_DRIVER_OK, DEVICE_FAILED, DEVICE_FEATURES_OK,
@ -35,8 +36,7 @@ use vm_device::interrupt::{
}; };
use vm_device::BusDevice; use vm_device::BusDevice;
use vm_memory::{ use vm_memory::{
Address, ByteValued, GuestAddress, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryMmap, Address, ByteValued, GuestAddress, GuestAddressSpace, GuestMemoryAtomic, GuestUsize, Le32,
GuestUsize, Le32,
}; };
use vm_migration::{ use vm_migration::{
Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable, VersionMapped, Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable, VersionMapped,

View File

@ -10,6 +10,7 @@ use super::vu_common_ctrl::{
}; };
use super::{Error, Result, DEFAULT_VIRTIO_FEATURES}; use super::{Error, Result, DEFAULT_VIRTIO_FEATURES};
use crate::VirtioInterrupt; use crate::VirtioInterrupt;
use crate::{GuestMemoryMmap, GuestRegionMmap};
use block_util::VirtioBlockConfig; use block_util::VirtioBlockConfig;
use std::mem; use std::mem;
use std::ops::Deref; use std::ops::Deref;
@ -27,9 +28,7 @@ use virtio_bindings::bindings::virtio_blk::{
VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_MQ, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_MQ, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_SEG_MAX,
VIRTIO_BLK_F_SIZE_MAX, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_WRITE_ZEROES, VIRTIO_BLK_F_SIZE_MAX, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_WRITE_ZEROES,
}; };
use vm_memory::{ use vm_memory::{ByteValued, GuestAddressSpace, GuestMemoryAtomic};
ByteValued, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryMmap, GuestRegionMmap,
};
use vm_migration::{Migratable, MigratableError, Pausable, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;

View File

@ -12,6 +12,7 @@ use crate::{
ActivateError, ActivateResult, Queue, UserspaceMapping, VirtioCommon, VirtioDevice, ActivateError, ActivateResult, Queue, UserspaceMapping, VirtioCommon, VirtioDevice,
VirtioDeviceType, VirtioInterrupt, VirtioSharedMemoryList, VirtioDeviceType, VirtioInterrupt, VirtioSharedMemoryList,
}; };
use crate::{GuestMemoryMmap, GuestRegionMmap, MmapRegion};
use libc::{self, c_void, off64_t, pread64, pwrite64}; use libc::{self, c_void, off64_t, pread64, pwrite64};
use seccomp::{SeccompAction, SeccompFilter}; use seccomp::{SeccompAction, SeccompFilter};
use std::io; use std::io;
@ -29,7 +30,6 @@ use vhost::vhost_user::{
}; };
use vm_memory::{ use vm_memory::{
Address, ByteValued, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic, Address, ByteValued, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic,
GuestMemoryMmap, GuestRegionMmap, MmapRegion,
}; };
use vm_migration::{Migratable, MigratableError, Pausable, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use crate::{ use crate::{
EpollHelper, EpollHelperError, EpollHelperHandler, Queue, VirtioInterrupt, EpollHelper, EpollHelperError, EpollHelperHandler, GuestMemoryMmap, Queue, VirtioInterrupt,
EPOLL_HELPER_EVENT_LAST, VIRTIO_F_IN_ORDER, VIRTIO_F_NOTIFICATION_DATA, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_IN_ORDER, VIRTIO_F_NOTIFICATION_DATA,
VIRTIO_F_ORDER_PLATFORM, VIRTIO_F_RING_EVENT_IDX, VIRTIO_F_RING_INDIRECT_DESC, VIRTIO_F_ORDER_PLATFORM, VIRTIO_F_RING_EVENT_IDX, VIRTIO_F_RING_INDIRECT_DESC,
VIRTIO_F_RING_PACKED, VIRTIO_F_VERSION_1, VIRTIO_F_RING_PACKED, VIRTIO_F_VERSION_1,
@ -14,7 +14,7 @@ use std::sync::{atomic::AtomicBool, Arc, Barrier, Mutex};
use vhost::vhost_user::message::VhostUserVirtioFeatures; 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, GuestMemoryMmap}; use vm_memory::{Error as MmapError, GuestAddressSpace, GuestMemoryAtomic};
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};

View File

@ -12,6 +12,7 @@ use crate::{
VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterrupt, EPOLL_HELPER_EVENT_LAST, VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterrupt, EPOLL_HELPER_EVENT_LAST,
VIRTIO_F_RING_EVENT_IDX, VIRTIO_F_VERSION_1, VIRTIO_F_RING_EVENT_IDX, VIRTIO_F_VERSION_1,
}; };
use crate::{GuestMemoryMmap, GuestRegionMmap};
use net_util::{build_net_config_space, CtrlQueue, MacAddr, VirtioNetConfig}; use net_util::{build_net_config_space, CtrlQueue, MacAddr, VirtioNetConfig};
use seccomp::{SeccompAction, SeccompFilter}; use seccomp::{SeccompAction, SeccompFilter};
use std::ops::Deref; use std::ops::Deref;
@ -29,9 +30,7 @@ use virtio_bindings::bindings::virtio_net::{
VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6, VIRTIO_NET_F_HOST_UFO,
VIRTIO_NET_F_MAC, VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_MAC, VIRTIO_NET_F_MRG_RXBUF,
}; };
use vm_memory::{ use vm_memory::{ByteValued, GuestAddressSpace, GuestMemoryAtomic};
ByteValued, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryMmap, GuestRegionMmap,
};
use vm_migration::{Migratable, MigratableError, Pausable, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;

View File

@ -4,6 +4,7 @@
use super::super::{Descriptor, Queue}; use super::super::{Descriptor, Queue};
use super::{Error, Result}; use super::{Error, Result};
use crate::{get_host_address_range, VirtioInterrupt, VirtioInterruptType}; use crate::{get_host_address_range, VirtioInterrupt, VirtioInterruptType};
use crate::{GuestMemoryMmap, GuestRegionMmap};
use std::convert::TryInto; use std::convert::TryInto;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::os::unix::net::UnixListener; use std::os::unix::net::UnixListener;
@ -14,9 +15,7 @@ use std::vec::Vec;
use vhost::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatures}; use vhost::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatures};
use vhost::vhost_user::{Master, VhostUserMaster}; use vhost::vhost_user::{Master, VhostUserMaster};
use vhost::{VhostBackend, VhostUserMemoryRegionInfo, VringConfigData}; use vhost::{VhostBackend, VhostUserMemoryRegionInfo, VringConfigData};
use vm_memory::{ use vm_memory::{Address, Error as MmapError, GuestMemory, GuestMemoryRegion};
Address, Error as MmapError, GuestMemory, GuestMemoryMmap, GuestMemoryRegion, GuestRegionMmap,
};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View File

@ -30,6 +30,7 @@
use super::{VsockBackend, VsockPacket}; use super::{VsockBackend, VsockPacket};
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
use crate::Error as DeviceError; use crate::Error as DeviceError;
use crate::GuestMemoryMmap;
use crate::VirtioInterrupt; use crate::VirtioInterrupt;
use crate::{ use crate::{
ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, Queue, ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, Queue,
@ -47,7 +48,7 @@ use std::sync::{Arc, Barrier, RwLock};
use std::thread; use std::thread;
use versionize::{VersionMap, Versionize, VersionizeResult}; use versionize::{VersionMap, Versionize, VersionizeResult};
use versionize_derive::Versionize; use versionize_derive::Versionize;
use vm_memory::{GuestAddressSpace, GuestMemoryAtomic, GuestMemoryMmap}; use vm_memory::{GuestAddressSpace, GuestMemoryAtomic};
use vm_migration::{ use vm_migration::{
Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable, VersionMapped, Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable, VersionMapped,
}; };

View File

@ -163,11 +163,12 @@ mod tests {
use crate::device::{VirtioInterrupt, VirtioInterruptType}; use crate::device::{VirtioInterrupt, VirtioInterruptType};
use crate::epoll_helper::EpollHelperHandler; use crate::epoll_helper::EpollHelperHandler;
use crate::EpollHelper; use crate::EpollHelper;
use crate::GuestMemoryMmap;
use libc::EFD_NONBLOCK; use libc::EFD_NONBLOCK;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use vm_memory::{GuestAddress, GuestMemoryAtomic, GuestMemoryMmap}; use vm_memory::{GuestAddress, GuestMemoryAtomic};
use vm_virtio::queue::testing::VirtQueue as GuestQ; use vm_virtio::queue::testing::VirtQueue as GuestQ;
use vm_virtio::queue::Queue; use vm_virtio::queue::Queue;
use vm_virtio::queue::{VIRTQ_DESC_F_NEXT, VIRTQ_DESC_F_WRITE}; use vm_virtio::queue::{VIRTQ_DESC_F_NEXT, VIRTQ_DESC_F_WRITE};

View File

@ -342,7 +342,8 @@ mod tests {
use super::super::tests::TestContext; use super::super::tests::TestContext;
use super::*; use super::*;
use crate::vsock::defs::MAX_PKT_BUF_SIZE; use crate::vsock::defs::MAX_PKT_BUF_SIZE;
use vm_memory::{GuestAddress, GuestMemoryMmap}; use crate::GuestMemoryMmap;
use vm_memory::GuestAddress;
use vm_virtio::queue::testing::VirtqDesc as GuestQDesc; use vm_virtio::queue::testing::VirtqDesc as GuestQDesc;
use vm_virtio::queue::VIRTQ_DESC_F_WRITE; use vm_virtio::queue::VIRTQ_DESC_F_WRITE;

View File

@ -11,6 +11,7 @@ use super::{
VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1, VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1,
}; };
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
use crate::GuestMemoryMmap;
use crate::{VirtioInterrupt, VirtioInterruptType}; use crate::{VirtioInterrupt, VirtioInterruptType};
use anyhow::anyhow; use anyhow::anyhow;
use seccomp::{SeccompAction, SeccompFilter}; use seccomp::{SeccompAction, SeccompFilter};
@ -24,7 +25,7 @@ use std::thread;
use std::time::Instant; use std::time::Instant;
use versionize::{VersionMap, Versionize, VersionizeResult}; use versionize::{VersionMap, Versionize, VersionizeResult};
use versionize_derive::Versionize; use versionize_derive::Versionize;
use vm_memory::{Bytes, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryMmap}; use vm_memory::{Bytes, GuestAddressSpace, GuestMemoryAtomic};
use vm_migration::VersionMapped; use vm_migration::VersionMapped;
use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;

View File

@ -10,4 +10,4 @@ default = []
[dependencies] [dependencies]
log = "0.4.14" log = "0.4.14"
virtio-bindings = { version = "0.1", features = ["virtio-v5_0_0"]} virtio-bindings = { version = "0.1", features = ["virtio-v5_0_0"]}
vm-memory = { version = "0.5.0", features = ["backend-mmap", "backend-atomic"] } vm-memory = { version = "0.5.0", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }

View File

@ -16,7 +16,7 @@ use std::num::Wrapping;
use std::sync::atomic::{fence, Ordering}; use std::sync::atomic::{fence, Ordering};
use std::sync::Arc; use std::sync::Arc;
use vm_memory::{ use vm_memory::{
Address, ByteValued, Bytes, GuestAddress, GuestMemory, GuestMemoryError, GuestMemoryMmap, bitmap::AtomicBitmap, Address, ByteValued, Bytes, GuestAddress, GuestMemory, GuestMemoryError,
GuestUsize, GuestUsize,
}; };
@ -24,6 +24,8 @@ pub const VIRTQ_DESC_F_NEXT: u16 = 0x1;
pub const VIRTQ_DESC_F_WRITE: u16 = 0x2; pub const VIRTQ_DESC_F_WRITE: u16 = 0x2;
pub const VIRTQ_DESC_F_INDIRECT: u16 = 0x4; pub const VIRTQ_DESC_F_INDIRECT: u16 = 0x4;
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
GuestMemoryError, GuestMemoryError,
@ -717,7 +719,9 @@ pub mod testing {
use std::marker::PhantomData; use std::marker::PhantomData;
use std::mem; use std::mem;
use vm_memory::Bytes; use vm_memory::Bytes;
use vm_memory::{Address, GuestAddress, GuestMemoryMmap, GuestUsize}; use vm_memory::{bitmap::AtomicBitmap, Address, GuestAddress, GuestUsize};
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;
// Represents a location in GuestMemoryMmap which holds a given type. // Represents a location in GuestMemoryMmap which holds a given type.
pub struct SomeplaceInMemory<'a, T> { pub struct SomeplaceInMemory<'a, T> {
@ -960,7 +964,9 @@ pub mod testing {
pub mod tests { pub mod tests {
use super::testing::*; use super::testing::*;
pub use super::*; pub use super::*;
use vm_memory::{GuestAddress, GuestMemoryMmap}; use vm_memory::{bitmap::AtomicBitmap, GuestAddress};
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;
#[test] #[test]
fn test_checked_new_descriptor_chain() { fn test_checked_new_descriptor_chain() {

View File

@ -47,7 +47,7 @@ vfio-ioctls = { git = "https://github.com/rust-vmm/vfio-ioctls", branch = "maste
virtio-devices = { path = "../virtio-devices" } virtio-devices = { path = "../virtio-devices" }
vm-allocator = { path = "../vm-allocator" } vm-allocator = { path = "../vm-allocator" }
vm-device = { path = "../vm-device" } vm-device = { path = "../vm-device" }
vm-memory = { version = "0.5.0", features = ["backend-mmap", "backend-atomic"] } vm-memory = { version = "0.5.0", features = ["backend-mmap", "backend-atomic", "backend-bitmap"] }
vm-migration = { path = "../vm-migration" } vm-migration = { path = "../vm-migration" }
vm-virtio = { path = "../vm-virtio" } vm-virtio = { path = "../vm-virtio" }
vmm-sys-util = { version = ">=0.5.0", features = ["with-serde"] } vmm-sys-util = { version = ">=0.5.0", features = ["with-serde"] }

View File

@ -6,6 +6,7 @@ use crate::cpu::CpuManager;
use crate::device_manager::DeviceManager; use crate::device_manager::DeviceManager;
use crate::memory_manager::MemoryManager; use crate::memory_manager::MemoryManager;
use crate::vm::NumaNodes; use crate::vm::NumaNodes;
use crate::{GuestMemoryMmap, GuestRegionMmap};
use acpi_tables::sdt::GenericAddress; use acpi_tables::sdt::GenericAddress;
use acpi_tables::{aml::Aml, rsdp::Rsdp, sdt::Sdt}; use acpi_tables::{aml::Aml, rsdp::Rsdp, sdt::Sdt};
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
@ -15,8 +16,7 @@ use arch::DeviceType;
use bitflags::bitflags; use bitflags::bitflags;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use vm_memory::GuestRegionMmap; use vm_memory::{Address, ByteValued, Bytes, GuestAddress, GuestMemoryRegion};
use vm_memory::{Address, ByteValued, Bytes, GuestAddress, GuestMemoryMmap, GuestMemoryRegion};
/* Values for Type in APIC sub-headers */ /* Values for Type in APIC sub-headers */
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]

View File

@ -19,6 +19,7 @@ use crate::memory_manager::MemoryManager;
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use crate::vm::physical_bits; use crate::vm::physical_bits;
use crate::GuestMemoryMmap;
use crate::CPU_MANAGER_SNAPSHOT_ID; use crate::CPU_MANAGER_SNAPSHOT_ID;
#[cfg(feature = "acpi")] #[cfg(feature = "acpi")]
use acpi_tables::{aml, aml::Aml, sdt::Sdt}; use acpi_tables::{aml, aml::Aml, sdt::Sdt};
@ -43,7 +44,7 @@ use std::{cmp, io, result, thread};
use vm_device::BusDevice; use vm_device::BusDevice;
#[cfg(feature = "acpi")] #[cfg(feature = "acpi")]
use vm_memory::GuestAddress; use vm_memory::GuestAddress;
use vm_memory::{GuestMemoryAtomic, GuestMemoryMmap}; use vm_memory::GuestMemoryAtomic;
use vm_migration::{ use vm_migration::{
Migratable, MigratableError, Pausable, Snapshot, SnapshotDataSection, Snapshottable, Migratable, MigratableError, Pausable, Snapshot, SnapshotDataSection, Snapshottable,
Transportable, Transportable,
@ -1775,6 +1776,7 @@ mod tests {
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::GuestMemoryMmap;
use arch::aarch64::layout; use arch::aarch64::layout;
use arch::aarch64::regs::*; use arch::aarch64::regs::*;
use hypervisor::kvm::aarch64::{is_system_register, MPIDR_EL1}; use hypervisor::kvm::aarch64::{is_system_register, MPIDR_EL1};
@ -1784,7 +1786,7 @@ mod tests {
}; };
use hypervisor::{arm64_core_reg_id, offset__of}; use hypervisor::{arm64_core_reg_id, offset__of};
use std::mem; use std::mem;
use vm_memory::{GuestAddress, GuestMemoryMmap}; use vm_memory::GuestAddress;
#[test] #[test]
fn test_setup_regs() { fn test_setup_regs() {

View File

@ -24,6 +24,7 @@ use crate::memory_manager::MEMORY_MANAGER_ACPI_SIZE;
use crate::memory_manager::{Error as MemoryManagerError, MemoryManager}; use crate::memory_manager::{Error as MemoryManagerError, MemoryManager};
#[cfg(feature = "acpi")] #[cfg(feature = "acpi")]
use crate::vm::NumaNodes; use crate::vm::NumaNodes;
use crate::GuestRegionMmap;
use crate::PciDeviceInfo; use crate::PciDeviceInfo;
use crate::{device_node, DEVICE_MANAGER_SNAPSHOT_ID}; use crate::{device_node, DEVICE_MANAGER_SNAPSHOT_ID};
#[cfg(feature = "acpi")] #[cfg(feature = "acpi")]
@ -93,7 +94,7 @@ use vm_device::{Bus, BusDevice, Resource};
use vm_memory::guest_memory::FileOffset; use vm_memory::guest_memory::FileOffset;
#[cfg(feature = "kvm")] #[cfg(feature = "kvm")]
use vm_memory::GuestMemoryRegion; use vm_memory::GuestMemoryRegion;
use vm_memory::{Address, GuestAddress, GuestRegionMmap, GuestUsize, MmapRegion}; use vm_memory::{Address, GuestAddress, GuestUsize, MmapRegion};
#[cfg(feature = "cmos")] #[cfg(feature = "cmos")]
use vm_memory::{GuestAddressSpace, GuestMemory}; use vm_memory::{GuestAddressSpace, GuestMemory};
use vm_migration::{ use vm_migration::{

View File

@ -40,6 +40,7 @@ use std::sync::mpsc::{Receiver, RecvError, SendError, Sender};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::{result, thread}; use std::{result, thread};
use thiserror::Error; use thiserror::Error;
use vm_memory::bitmap::AtomicBitmap;
use vm_migration::protocol::*; use vm_migration::protocol::*;
use vm_migration::{MigratableError, Pausable, Snapshot, Snapshottable, Transportable}; use vm_migration::{MigratableError, Pausable, Snapshot, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
@ -58,6 +59,9 @@ pub mod vm;
#[cfg(feature = "acpi")] #[cfg(feature = "acpi")]
mod acpi; mod acpi;
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;
type GuestRegionMmap = vm_memory::GuestRegionMmap<AtomicBitmap>;
/// Errors associated with VMM management /// Errors associated with VMM management
#[derive(Debug, Error)] #[derive(Debug, Error)]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]

View File

@ -7,6 +7,7 @@ use crate::config::SgxEpcConfig;
use crate::config::{HotplugMethod, MemoryConfig, MemoryZoneConfig}; use crate::config::{HotplugMethod, MemoryConfig, MemoryZoneConfig};
use crate::migration::url_to_path; use crate::migration::url_to_path;
use crate::MEMORY_MANAGER_SNAPSHOT_ID; use crate::MEMORY_MANAGER_SNAPSHOT_ID;
use crate::{GuestMemoryMmap, GuestRegionMmap};
#[cfg(feature = "acpi")] #[cfg(feature = "acpi")]
use acpi_tables::{aml, aml::Aml}; use acpi_tables::{aml, aml::Aml};
use anyhow::anyhow; use anyhow::anyhow;
@ -36,8 +37,8 @@ use vm_device::BusDevice;
use vm_memory::guest_memory::FileOffset; use vm_memory::guest_memory::FileOffset;
use vm_memory::{ use vm_memory::{
mmap::MmapRegionError, Address, Bytes, Error as MmapError, GuestAddress, GuestAddressSpace, mmap::MmapRegionError, Address, Bytes, Error as MmapError, GuestAddress, GuestAddressSpace,
GuestMemory, GuestMemoryAtomic, GuestMemoryError, GuestMemoryLoadGuard, GuestMemoryMmap, GuestMemory, GuestMemoryAtomic, GuestMemoryError, GuestMemoryLoadGuard, GuestMemoryRegion,
GuestMemoryRegion, GuestRegionMmap, GuestUsize, MmapRegion, GuestUsize, MmapRegion,
}; };
use vm_migration::{ use vm_migration::{
protocol::{MemoryRange, MemoryRangeTable}, protocol::{MemoryRange, MemoryRangeTable},

View File

@ -25,6 +25,7 @@ use crate::device_tree::DeviceTree;
use crate::memory_manager::{Error as MemoryManagerError, MemoryManager}; use crate::memory_manager::{Error as MemoryManagerError, MemoryManager};
use crate::migration::{get_vm_snapshot, url_to_path, VM_SNAPSHOT_FILE}; use crate::migration::{get_vm_snapshot, url_to_path, VM_SNAPSHOT_FILE};
use crate::seccomp_filters::{get_seccomp_filter, Thread}; use crate::seccomp_filters::{get_seccomp_filter, Thread};
use crate::{GuestMemoryMmap, GuestRegionMmap};
use crate::{ use crate::{
PciDeviceInfo, CPU_MANAGER_SNAPSHOT_ID, DEVICE_MANAGER_SNAPSHOT_ID, MEMORY_MANAGER_SNAPSHOT_ID, PciDeviceInfo, CPU_MANAGER_SNAPSHOT_ID, DEVICE_MANAGER_SNAPSHOT_ID, MEMORY_MANAGER_SNAPSHOT_ID,
}; };
@ -61,7 +62,7 @@ use std::{result, str, thread};
use vm_device::Bus; use vm_device::Bus;
use vm_memory::{ use vm_memory::{
Address, Bytes, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic, Address, Bytes, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic,
GuestMemoryMmap, GuestMemoryRegion, GuestRegionMmap, GuestMemoryRegion,
}; };
use vm_migration::{ use vm_migration::{
protocol::{MemoryRange, MemoryRangeTable}, protocol::{MemoryRange, MemoryRangeTable},
@ -2435,11 +2436,12 @@ mod tests {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::{GuestMemoryMmap, GuestRegionMmap};
use arch::aarch64::fdt::create_fdt; use arch::aarch64::fdt::create_fdt;
use arch::aarch64::gic::kvm::create_gic; use arch::aarch64::gic::kvm::create_gic;
use arch::aarch64::{layout, DeviceInfoForFdt}; use arch::aarch64::{layout, DeviceInfoForFdt};
use arch::{DeviceType, MmioDeviceInfo}; use arch::{DeviceType, MmioDeviceInfo};
use vm_memory::{GuestAddress, GuestMemoryMmap}; use vm_memory::GuestAddress;
const LEN: u64 = 4096; const LEN: u64 = 4096;