Crates.io | hv |
lib.rs | hv |
version | 0.1.2 |
source | src |
created_at | 2021-06-29 20:04:10.501712 |
updated_at | 2022-01-27 17:59:05.90246 |
description | High level Rust bidings to Hypervisor Framework |
homepage | |
repository | https://github.com/cloud-hypervisor/hypervisor-framework |
max_upload_size | |
id | 416336 |
size | 69,403 |
hv
is a high level Rust bindings for Hypervisor Framework.
Build virtualization solutions on top of a lightweight hypervisor using Rust:
Please also see the repository for latest changes and updates.
At runtime, determine whether the Hypervisor APIs are available on a particular machine with the sysctl
:
$ sysctl kern.hv_support
kern.hv_support: 1
In order to use Hypervisor API your app must have com.apple.security.hypervisor
entitlement.
Refer to example.entitlements for example of how entitlement file might look like.
Use the following command to self sign your binary for local development:
$ codesign --sign - --force --entitlements=example.entitlements ./binary
Developed and tested on latest stable Rust (1.53.0+).
Be sure to have Xcode installed and don't forget to xcode-select --install
,
otherwise bindgen
may fail to find Hypervisor headers.
This crate uses hv-sys
Here is basic "Hello world" example on Apple Silicon:
// Init VM
let vm = Arc::new(hv::Vm::new(std::ptr::null_mut())?);
// Initialize guest memory
vm.map(load_addr, GUEST_ADDR, MEM_SIZE, hv::Memory::READ)?;
// Create VCPU
let cpu = vm.create_cpu()?;
// Set regs
cpu.set_reg(Reg::PC, GUEST_ADDR)?
cpu.set_reg(Reg::X1, GUEST_RESULT_ADDR)?
loop {
cpu.run().expect("Failed to run CPU");
let info = cpu.exit_info();
println!("{:?}", info);
break;
}