mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-10 14:47:42 +00:00
vmm: use MemoryRegion where applicable
That removes one more KVM-ism in VMM crate. Note that there are more KVM specific code in those files to be split out, but we're not at that stage yet. No functional change. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
48a05c4727
commit
b00171e17d
@ -590,7 +590,7 @@ impl DeviceRelocation for AddressManager {
|
||||
if let Some(mut shm_regions) = virtio_dev.get_shm_regions() {
|
||||
if shm_regions.addr.raw_value() == old_base {
|
||||
// Remove old region from KVM by passing a size of 0.
|
||||
let mut mem_region = hypervisor::kvm::kvm_userspace_memory_region {
|
||||
let mut mem_region = hypervisor::MemoryRegion {
|
||||
slot: shm_regions.mem_slot,
|
||||
guest_phys_addr: old_base,
|
||||
memory_size: 0,
|
||||
|
@ -13,8 +13,6 @@ use arch::{get_host_cpu_phys_bits, layout, RegionType};
|
||||
use devices::ioapic;
|
||||
use devices::BusDevice;
|
||||
|
||||
use hypervisor::kvm::{kvm_userspace_memory_region, KVM_MEM_READONLY};
|
||||
|
||||
use std::convert::TryInto;
|
||||
use std::ffi;
|
||||
use std::fs::{File, OpenOptions};
|
||||
@ -678,12 +676,16 @@ impl MemoryManager {
|
||||
readonly: bool,
|
||||
) -> Result<u32, Error> {
|
||||
let slot = self.allocate_kvm_memory_slot();
|
||||
let mem_region = kvm_userspace_memory_region {
|
||||
let mem_region = hypervisor::MemoryRegion {
|
||||
slot,
|
||||
guest_phys_addr,
|
||||
memory_size,
|
||||
userspace_addr,
|
||||
flags: if readonly { KVM_MEM_READONLY } else { 0 },
|
||||
flags: if readonly {
|
||||
hypervisor::kvm::KVM_MEM_READONLY
|
||||
} else {
|
||||
0
|
||||
},
|
||||
};
|
||||
|
||||
self.fd
|
||||
@ -731,7 +733,7 @@ impl MemoryManager {
|
||||
mergeable: bool,
|
||||
slot: u32,
|
||||
) -> Result<(), Error> {
|
||||
let mem_region = kvm_userspace_memory_region {
|
||||
let mem_region = hypervisor::MemoryRegion {
|
||||
slot,
|
||||
guest_phys_addr,
|
||||
memory_size: 0,
|
||||
|
@ -1451,7 +1451,7 @@ pub fn test_vm() {
|
||||
let vm_fd = hv.create_vm().expect("new VM fd creation failed");
|
||||
|
||||
mem.with_regions(|index, region| {
|
||||
let mem_region = hypervisor::kvm_userspace_memory_region {
|
||||
let mem_region = hypervisor::MemoryRegion {
|
||||
slot: index as u32,
|
||||
guest_phys_addr: region.start_addr().raw_value(),
|
||||
memory_size: region.len() as u64,
|
||||
|
Loading…
Reference in New Issue
Block a user