Skip to content

Commit

Permalink
volatile_memory: add VolatileArrayRef
Browse files Browse the repository at this point in the history
Allow easily access to an array stored in a VolatileMemory object, removing
the need to do multiplications and pointer offsetting.  It also generalizes
the existing methods copy_to and copy_from in VolatileSlice.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Jun 4, 2019
1 parent 929c2fc commit 6b039b3
Show file tree
Hide file tree
Showing 4 changed files with 326 additions and 21 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ backend-mmap = []

[dependencies]
libc = ">=0.2.39"
cast = ">=0"

[dev-dependencies]
matches = ">=0"
Expand Down
1 change: 1 addition & 0 deletions src/guest_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl From<volatile_memory::Error> for Error {
match e {
volatile_memory::Error::OutOfBounds { .. } => Error::InvalidBackendAddress,
volatile_memory::Error::Overflow { .. } => Error::InvalidBackendAddress,
volatile_memory::Error::TooBig { .. } => Error::InvalidBackendAddress,
volatile_memory::Error::IOError(e) => Error::IOError(e),
volatile_memory::Error::PartialBuffer {
expected,
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ pub use mmap::{GuestMemoryMmap, GuestRegionMmap, MmapError, MmapRegion};

pub mod volatile_memory;
pub use volatile_memory::{
Error as VolatileMemoryError, Result as VolatileMemoryResult, VolatileMemory, VolatileRef,
VolatileSlice,
Error as VolatileMemoryError, Result as VolatileMemoryResult, VolatileArrayRef, VolatileMemory,
VolatileRef, VolatileSlice,
};
Loading

0 comments on commit 6b039b3

Please sign in to comment.