mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
hypervisor: Add control for dirty page logging
When creating a userspace mapping provide a control for enabling the logging of dirty pages. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
b399287430
commit
8baa244ec1
@ -70,7 +70,8 @@ use std::mem;
|
||||
pub use kvm_bindings;
|
||||
pub use kvm_bindings::{
|
||||
kvm_create_device, kvm_device_type_KVM_DEV_TYPE_VFIO, kvm_irq_routing, kvm_irq_routing_entry,
|
||||
kvm_userspace_memory_region, KVM_IRQ_ROUTING_MSI, KVM_MEM_READONLY, KVM_MSI_VALID_DEVID,
|
||||
kvm_userspace_memory_region, KVM_IRQ_ROUTING_MSI, KVM_MEM_LOG_DIRTY_PAGES, KVM_MEM_READONLY,
|
||||
KVM_MSI_VALID_DEVID,
|
||||
};
|
||||
pub use kvm_ioctls;
|
||||
pub use kvm_ioctls::{Cap, Kvm};
|
||||
@ -255,13 +256,19 @@ impl vm::Vm for KvmVm {
|
||||
memory_size: u64,
|
||||
userspace_addr: u64,
|
||||
readonly: bool,
|
||||
log_dirty_pages: bool,
|
||||
) -> MemoryRegion {
|
||||
MemoryRegion {
|
||||
slot,
|
||||
guest_phys_addr,
|
||||
memory_size,
|
||||
userspace_addr,
|
||||
flags: if readonly { KVM_MEM_READONLY } else { 0 },
|
||||
flags: if readonly { KVM_MEM_READONLY } else { 0 }
|
||||
| if log_dirty_pages {
|
||||
KVM_MEM_LOG_DIRTY_PAGES
|
||||
} else {
|
||||
0
|
||||
},
|
||||
}
|
||||
}
|
||||
///
|
||||
|
@ -189,6 +189,7 @@ pub trait Vm: Send + Sync {
|
||||
memory_size: u64,
|
||||
userspace_addr: u64,
|
||||
readonly: bool,
|
||||
log_dirty_pages: bool,
|
||||
) -> MemoryRegion;
|
||||
/// Creates/modifies a guest physical memory slot.
|
||||
fn set_user_memory_region(&self, user_memory_region: MemoryRegion) -> Result<()>;
|
||||
|
@ -561,6 +561,7 @@ impl VfioPciDevice {
|
||||
mmap_size as u64,
|
||||
host_addr as u64,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
|
||||
vm.set_user_memory_region(mem_region)
|
||||
@ -590,6 +591,7 @@ impl VfioPciDevice {
|
||||
0,
|
||||
host_addr as u64,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
|
||||
if let Err(e) = self.vm.set_user_memory_region(r) {
|
||||
@ -1012,6 +1014,7 @@ impl PciDevice for VfioPciDevice {
|
||||
0,
|
||||
host_addr as u64,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
|
||||
self.vm
|
||||
@ -1025,6 +1028,7 @@ impl PciDevice for VfioPciDevice {
|
||||
mmap_size as u64,
|
||||
host_addr as u64,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
|
||||
self.vm
|
||||
|
@ -612,6 +612,7 @@ impl DeviceRelocation for AddressManager {
|
||||
0,
|
||||
shm_regions.host_addr,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
|
||||
self.vm.set_user_memory_region(mem_region).map_err(|e| {
|
||||
@ -628,6 +629,7 @@ impl DeviceRelocation for AddressManager {
|
||||
shm_regions.len,
|
||||
shm_regions.host_addr,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
|
||||
self.vm.set_user_memory_region(mem_region).map_err(|e| {
|
||||
|
@ -1115,6 +1115,7 @@ impl MemoryManager {
|
||||
memory_size,
|
||||
userspace_addr,
|
||||
readonly,
|
||||
false,
|
||||
);
|
||||
|
||||
self.vm
|
||||
@ -1168,6 +1169,7 @@ impl MemoryManager {
|
||||
0, /* memory_size -- using 0 removes this slot */
|
||||
userspace_addr,
|
||||
false, /* readonly -- don't care */
|
||||
false, /* log dirty */
|
||||
);
|
||||
|
||||
self.vm
|
||||
|
@ -2131,6 +2131,7 @@ pub fn test_vm() {
|
||||
region.len() as u64,
|
||||
region.as_ptr() as u64,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
|
||||
vm.set_user_memory_region(mem_region)
|
||||
|
Loading…
Reference in New Issue
Block a user