forked from rust-vmm/vm-memory
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
79 lines (63 loc) · 2.86 KB
/
lib.rs
File metadata and controls
79 lines (63 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Portions Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Portions Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-BSD-3-Clause file.
//
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
//! Traits for allocating, handling and interacting with the VM's physical memory.
//!
//! For a typical hypervisor, there are several components, such as boot loader, virtual device
//! drivers, virtio backend drivers and vhost drivers etc, that need to access VM's physical memory.
//! This crate aims to provide a set of stable traits to decouple VM memory consumers from VM
//! memory providers. Based on these traits, VM memory consumers could access VM's physical memory
//! without knowing the implementation details of the VM memory provider. Thus hypervisor
//! components, such as boot loader, virtual device drivers, virtio backend drivers and vhost
//! drivers etc, could be shared and reused by multiple hypervisors.
#![warn(clippy::doc_markdown)]
#![warn(missing_docs)]
#![warn(missing_debug_implementations)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
// We only support 64bit. Fail build when attempting to build other targets
#[cfg(not(target_pointer_width = "64"))]
compile_error!("vm-memory only supports 64-bit targets!");
#[cfg(all(target_family = "windows", feature = "rawfd"))]
compile_error!("rawfd feature is not supported on Windows targets!");
#[cfg(all(target_family = "windows", feature = "xen"))]
compile_error!("xen feature is not supported on Windows targets!");
#[macro_use]
pub mod address;
pub use address::{Address, AddressValue};
#[cfg(feature = "backend-atomic")]
pub mod atomic;
#[cfg(feature = "backend-atomic")]
pub use atomic::{GuestMemoryAtomic, GuestMemoryLoadGuard};
mod atomic_integer;
pub use atomic_integer::AtomicInteger;
pub mod bitmap;
pub mod bytes;
pub use bytes::{AtomicAccess, ByteValued, Bytes};
pub mod endian;
pub use endian::{Be16, Be32, Be64, BeSize, Le16, Le32, Le64, LeSize};
pub mod guest_memory;
pub use guest_memory::{
Error as GuestMemoryError, FileOffset, GuestAddress, GuestAddressSpace, GuestMemory,
GuestUsize, MemoryRegionAddress, Result as GuestMemoryResult,
};
pub mod region;
pub use region::{
GuestMemoryRegion, GuestMemoryRegionBytes, GuestRegionCollection, GuestRegionCollectionError,
};
pub mod io;
pub use io::{ReadVolatile, WriteVolatile};
#[cfg(feature = "backend-mmap")]
pub mod mmap;
#[cfg(feature = "backend-mmap")]
pub use mmap::{GuestMemoryMmap, GuestRegionMmap, MmapRegion};
#[cfg(all(feature = "backend-mmap", feature = "xen", target_family = "unix"))]
pub use mmap::{MmapRange, MmapXenFlags};
pub mod volatile_memory;
pub use volatile_memory::{
Error as VolatileMemoryError, Result as VolatileMemoryResult, VolatileArrayRef, VolatileMemory,
VolatileRef, VolatileSlice,
};