mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-22 12:35:19 +00:00
vmm: Create guest memory regions without dirty-pages-log by default
With the support of dynamically turning on/off dirty-pages-log during live-migration (only for guest RAM regions), we now can create guest memory regions without dirty-pages-log by default both for guest RAM regions and other regions backed by file/device. Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
5e0d498582
commit
f063346de3
@ -2233,9 +2233,7 @@ impl DeviceManager {
|
|||||||
.memory_manager
|
.memory_manager
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.create_userspace_mapping(
|
.create_userspace_mapping(cache_base, cache_size, host_addr, false, false)
|
||||||
cache_base, cache_size, host_addr, false, false, false,
|
|
||||||
)
|
|
||||||
.map_err(DeviceManagerError::MemoryManager)?;
|
.map_err(DeviceManagerError::MemoryManager)?;
|
||||||
|
|
||||||
let region_list = vec![VirtioSharedMemory {
|
let region_list = vec![VirtioSharedMemory {
|
||||||
@ -2427,7 +2425,6 @@ impl DeviceManager {
|
|||||||
host_addr,
|
host_addr,
|
||||||
pmem_cfg.mergeable,
|
pmem_cfg.mergeable,
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
)
|
)
|
||||||
.map_err(DeviceManagerError::MemoryManager)?;
|
.map_err(DeviceManagerError::MemoryManager)?;
|
||||||
|
|
||||||
|
@ -139,7 +139,6 @@ pub struct MemoryManager {
|
|||||||
user_provided_zones: bool,
|
user_provided_zones: bool,
|
||||||
snapshot_memory_regions: Vec<MemoryRegion>,
|
snapshot_memory_regions: Vec<MemoryRegion>,
|
||||||
memory_zones: MemoryZones,
|
memory_zones: MemoryZones,
|
||||||
log_dirty: bool, // Enable dirty logging for created RAM regions
|
|
||||||
|
|
||||||
// Keep track of calls to create_userspace_mapping() for guest RAM.
|
// Keep track of calls to create_userspace_mapping() for guest RAM.
|
||||||
// This is useful for getting the dirty pages as we need to know the
|
// This is useful for getting the dirty pages as we need to know the
|
||||||
@ -510,7 +509,6 @@ impl MemoryManager {
|
|||||||
config: &MemoryConfig,
|
config: &MemoryConfig,
|
||||||
prefault: bool,
|
prefault: bool,
|
||||||
phys_bits: u8,
|
phys_bits: u8,
|
||||||
#[cfg(feature = "tdx")] tdx_enabled: bool,
|
|
||||||
) -> Result<Arc<Mutex<MemoryManager>>, Error> {
|
) -> Result<Arc<Mutex<MemoryManager>>, Error> {
|
||||||
let user_provided_zones = config.size == 0;
|
let user_provided_zones = config.size == 0;
|
||||||
let mut allow_mem_hotplug: bool = false;
|
let mut allow_mem_hotplug: bool = false;
|
||||||
@ -749,11 +747,6 @@ impl MemoryManager {
|
|||||||
.allocate_mmio_addresses(None, MEMORY_MANAGER_ACPI_SIZE as u64, None)
|
.allocate_mmio_addresses(None, MEMORY_MANAGER_ACPI_SIZE as u64, None)
|
||||||
.ok_or(Error::AllocateMmioAddress)?;
|
.ok_or(Error::AllocateMmioAddress)?;
|
||||||
|
|
||||||
#[cfg(not(feature = "tdx"))]
|
|
||||||
let log_dirty = true;
|
|
||||||
#[cfg(feature = "tdx")]
|
|
||||||
let log_dirty = !tdx_enabled; // Cannot log dirty pages on a TD
|
|
||||||
|
|
||||||
let memory_manager = Arc::new(Mutex::new(MemoryManager {
|
let memory_manager = Arc::new(Mutex::new(MemoryManager {
|
||||||
boot_guest_memory,
|
boot_guest_memory,
|
||||||
guest_memory: guest_memory.clone(),
|
guest_memory: guest_memory.clone(),
|
||||||
@ -781,7 +774,6 @@ impl MemoryManager {
|
|||||||
guest_ram_mappings: Vec::new(),
|
guest_ram_mappings: Vec::new(),
|
||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
acpi_address,
|
acpi_address,
|
||||||
log_dirty,
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
for region in guest_memory.memory().iter() {
|
for region in guest_memory.memory().iter() {
|
||||||
@ -792,7 +784,6 @@ impl MemoryManager {
|
|||||||
region.as_ptr() as u64,
|
region.as_ptr() as u64,
|
||||||
config.mergeable,
|
config.mergeable,
|
||||||
false,
|
false,
|
||||||
log_dirty,
|
|
||||||
)?;
|
)?;
|
||||||
mm.guest_ram_mappings.push(GuestRamMapping {
|
mm.guest_ram_mappings.push(GuestRamMapping {
|
||||||
gpa: region.start_addr().raw_value(),
|
gpa: region.start_addr().raw_value(),
|
||||||
@ -809,7 +800,6 @@ impl MemoryManager {
|
|||||||
region.as_ptr() as u64,
|
region.as_ptr() as u64,
|
||||||
config.mergeable,
|
config.mergeable,
|
||||||
false,
|
false,
|
||||||
log_dirty,
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
mm.guest_ram_mappings.push(GuestRamMapping {
|
mm.guest_ram_mappings.push(GuestRamMapping {
|
||||||
@ -845,14 +835,7 @@ impl MemoryManager {
|
|||||||
prefault: bool,
|
prefault: bool,
|
||||||
phys_bits: u8,
|
phys_bits: u8,
|
||||||
) -> Result<Arc<Mutex<MemoryManager>>, Error> {
|
) -> Result<Arc<Mutex<MemoryManager>>, Error> {
|
||||||
let mm = MemoryManager::new(
|
let mm = MemoryManager::new(vm, config, prefault, phys_bits)?;
|
||||||
vm,
|
|
||||||
config,
|
|
||||||
prefault,
|
|
||||||
phys_bits,
|
|
||||||
#[cfg(feature = "tdx")]
|
|
||||||
false,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
if let Some(source_url) = source_url {
|
if let Some(source_url) = source_url {
|
||||||
let vm_snapshot_path = url_to_path(source_url).map_err(Error::Restore)?;
|
let vm_snapshot_path = url_to_path(source_url).map_err(Error::Restore)?;
|
||||||
@ -1118,7 +1101,6 @@ impl MemoryManager {
|
|||||||
region.as_ptr() as u64,
|
region.as_ptr() as u64,
|
||||||
self.mergeable,
|
self.mergeable,
|
||||||
false,
|
false,
|
||||||
self.log_dirty,
|
|
||||||
)?;
|
)?;
|
||||||
self.guest_ram_mappings.push(GuestRamMapping {
|
self.guest_ram_mappings.push(GuestRamMapping {
|
||||||
gpa: region.start_addr().raw_value(),
|
gpa: region.start_addr().raw_value(),
|
||||||
@ -1210,7 +1192,6 @@ impl MemoryManager {
|
|||||||
userspace_addr: u64,
|
userspace_addr: u64,
|
||||||
mergeable: bool,
|
mergeable: bool,
|
||||||
readonly: bool,
|
readonly: bool,
|
||||||
log_dirty: bool,
|
|
||||||
) -> Result<u32, Error> {
|
) -> Result<u32, Error> {
|
||||||
let slot = self.allocate_memory_slot();
|
let slot = self.allocate_memory_slot();
|
||||||
let mem_region = self.vm.make_user_memory_region(
|
let mem_region = self.vm.make_user_memory_region(
|
||||||
@ -1219,7 +1200,7 @@ impl MemoryManager {
|
|||||||
memory_size,
|
memory_size,
|
||||||
userspace_addr,
|
userspace_addr,
|
||||||
readonly,
|
readonly,
|
||||||
log_dirty,
|
false, // Always create memory regions without dirty pages log
|
||||||
);
|
);
|
||||||
|
|
||||||
self.vm
|
self.vm
|
||||||
@ -1455,7 +1436,6 @@ impl MemoryManager {
|
|||||||
host_addr,
|
host_addr,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
sgx_epc_region.insert(
|
sgx_epc_region.insert(
|
||||||
|
@ -765,8 +765,6 @@ impl Vm {
|
|||||||
&config.lock().unwrap().memory.clone(),
|
&config.lock().unwrap().memory.clone(),
|
||||||
false,
|
false,
|
||||||
phys_bits,
|
phys_bits,
|
||||||
#[cfg(feature = "tdx")]
|
|
||||||
tdx_enabled,
|
|
||||||
)
|
)
|
||||||
.map_err(Error::MemoryManager)?;
|
.map_err(Error::MemoryManager)?;
|
||||||
|
|
||||||
@ -887,8 +885,6 @@ impl Vm {
|
|||||||
&config.lock().unwrap().memory.clone(),
|
&config.lock().unwrap().memory.clone(),
|
||||||
false,
|
false,
|
||||||
phys_bits,
|
phys_bits,
|
||||||
#[cfg(feature = "tdx")]
|
|
||||||
false,
|
|
||||||
)
|
)
|
||||||
.map_err(Error::MemoryManager)?;
|
.map_err(Error::MemoryManager)?;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user