cloud-hypervisor/vendor/git-3e7c44ea7d5fd800/vm-memory
Sebastien Boeuf 842515c2f1 vendor: Add vmm-sys-util duplicate
Since the top-level Cargo.toml specifies a vmm-sys-util revision
but not the sub crates, Cargo.lock points at 2 different crates.
cargo vendor copies both of them into the vendor directory but
forces the build to use the one coming from the top level driven
requirement.

Although this is a waste of space, this is a cargo vendor limitation
that we have to live with for now.

Also, because the dependency onto linux-loader had to be updated,
we had to specify a newly introduced feature called "elf".

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-06-06 10:12:04 +02:00
..
.buildkite vendor: Add vmm-sys-util duplicate 2019-06-06 10:12:04 +02:00
.cargo vendor: Add vendored dependencies 2019-06-04 17:51:52 +02:00
src vendor: Add vendored dependencies 2019-06-04 17:51:52 +02:00
.cargo-checksum.json vendor: Add vmm-sys-util duplicate 2019-06-06 10:12:04 +02:00
Cargo.toml vendor: Add vendored dependencies 2019-06-04 17:51:52 +02:00
DESIGN.md vendor: Add vendored dependencies 2019-06-04 17:51:52 +02:00
LICENSE vendor: Add vendored dependencies 2019-06-04 17:51:52 +02:00
README.md vendor: Add vendored dependencies 2019-06-04 17:51:52 +02:00
THIRD-PARTY vendor: Add vendored dependencies 2019-06-04 17:51:52 +02:00
TODO.md vendor: Add vendored dependencies 2019-06-04 17:51:52 +02:00

vm-memory

A library to access virtual machine's physical memory.

For a typical hypervisor, there are seveval components, such as boot loader, virtual device drivers, virtio backend drivers and vhost drivers etc, need to access VM's physical memory. The vm-memory crate provides a set of 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 based on these traits could be shared and reused by multiple hypervisors.

Platform Support

  • Arch: x86, AMD64, ARM64
  • OS: Linux/Unix/Windows

Usage

First, add the following to your Cargo.toml:

vm-memory = "0.1"

Next, add this to your crate root:

extern crate vm_memory;

Example

  • Create VM physical memory objects in hypervisor specific ways. Use the default GuestMemoryMmap as an example:
    fn provide_mem_to_virt_dev() {
        let gm = GuestMemoryMmap::new(&[(GuestAddress(0), 0x1000), (GuestAddress(0x1000), 0x1000)]).unwrap();
        virt_device_io(&gm);
    }
  • Consumers access VM's physical memory
    fn virt_device_io<T: GuestMemory>(mem: &T) {
        let sample_buf = &[1, 2, 3, 4, 5];
        assert_eq!(mem.write(sample_buf, GuestAddress(0xffc)).unwrap(), 5);
        let buf = &mut [0u8; 5];
        assert_eq!(mem.read(buf, GuestAddress(0xffc)).unwrap(), 5);
        assert_eq!(buf, sample_buf);
    }

Documentations & References

License

This project is licensed under