目录
chyyuu

Fix errors in cargo clippy

Error info:

chyyuu:RVM$ cargo clippy Checking rvm v1.2.0 (/media/chyyuu/ca8c7ba6-51b7-41fc-8430-e29e31e5328f/thecode/rust/third-parts/RVM) error: this expression borrows a reference (&arch::vmcs::AutoVmcs) that is immediately dereferenced by the compiler –> src/arch/x86_64/vmexit.rs:729:30 | 729 | guest_state.dump(&vmcs), | ^^^^^ help: change this to: vmcs | note: the lint level is defined here –> src/lib.rs:9:9 | 9 | #![deny(warnings)] | ^^^^^^^^ = note: #[deny(clippy::needless_borrow)] implied by #[deny(warnings)] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

error: called is_none() after searching an Iterator with find –> src/dummy.rs:146:9 | 146 | / self.regions 147 | | .lock() 148 | | .iter() 149 | | .find(|region| region.is_overlap_with(start_paddr, end_paddr)) 150 | | .is_none() | |______________________^ | note: the lint level is defined here –> src/lib.rs:9:9 | 9 | #![deny(warnings)] | ^^^^^^^^ = note: #[deny(clippy::search_is_some)] implied by #[deny(warnings)] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some help: use !_.any() instead | 146 | !self.regions 147 | .lock() 148 | .iter().any(|region| region.is_overlap_with(start_paddr, end_paddr)) |

error: could not compile rvm due to 2 previous errors

3年前59次提交
目录README.md

RVM – Rcore Virtual Machine

CI

An experimental hypervisor library written in Rust to build both type-1 and type-2 hypervisors.

Supported architecture: x86_64 (Intel VMX).

rustc info

  • current rustc – rustc 1.56.0-nightly (08095fc1f 2021-07-26)
  • current rust-toolchain – nightly

Basic usage

See the UEFI example for more details.

use rvm::*;

const ENTRY: u64 = 0x2000;

fn run_hypervisor() -> RvmResult {
    // create a guest physical memory set.
    let gpm = DefaultGuestPhysMemorySet::new();

    // create a guest.
    let guest = Guest::new(gpm)?;

    // create a vcpu.
    let mut vcpu = Vcpu::new(ENTRY, guest.clone())?;

    // map the guest physical memory region [0, 0x8000) to the host phyical
    // memory region [0xC0000, 0xC8000).
    let host_paddr = 0xC0000;
    guest.add_memory_region(0, 0x8000, Some(0xC0000))?;

    // I/O instructions with port 0x233-0x234 can cause VM exit and `vcpu.resume()`
    // to return.
    guest.set_trap(TrapKind::GuestTrapIo, 0x233, 2, None, 0xdeadbeef)?;

    // The bootstrap processor is in IA-32e mode and enabled paging, you need to
    // setup guest page table.
    setup_guest_page_table(host_paddr);

    // run the VCPU and block, until the specified traps occurs.
    let packet = vcpu.resume()?;

    // get the VCPU state.
    let state = vcpu.read_state()?;

    Ok(())
}

More examples

RVM is used as the hypervisor module of the following OSes:

It can also run in linux as a kernel module and replace the KVM hypervisor to support simple guest OSes such as uCore. See the ko example and rcore-vmm for more details.

Documents

关于

Rcore Virtual Machine

1.4 MB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号