Skip to content

Commit 5ac5d47

Browse files
committed
refactor: Eliminate VmResources::track_dirty_pages getter
All other fields of `VmResources` and the contained `VmConfig` struct are accessed directly, with `track_dirty_pages` being the odd one out. Let's make it uniform. Signed-off-by: Patrick Roy <[email protected]>
1 parent d772c0f commit 5ac5d47

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

src/vmm/src/builder.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,6 @@ pub fn build_microvm_for_boot(
252252
.boot_source_builder()
253253
.ok_or(MissingKernelConfig)?;
254254

255-
let track_dirty_pages = vm_resources.track_dirty_pages();
256-
257255
let vhost_user_device_used = vm_resources
258256
.block
259257
.devices
@@ -272,15 +270,15 @@ pub fn build_microvm_for_boot(
272270
let guest_memory = if vhost_user_device_used {
273271
GuestMemoryMmap::memfd_backed(
274272
vm_resources.vm_config.mem_size_mib,
275-
track_dirty_pages,
273+
vm_resources.vm_config.track_dirty_pages,
276274
vm_resources.vm_config.huge_pages,
277275
)
278276
.map_err(StartMicrovmError::GuestMemory)?
279277
} else {
280278
let regions = crate::arch::arch_memory_regions(vm_resources.vm_config.mem_size_mib << 20);
281279
GuestMemoryMmap::from_raw_regions(
282280
&regions,
283-
track_dirty_pages,
281+
vm_resources.vm_config.track_dirty_pages,
284282
vm_resources.vm_config.huge_pages,
285283
)
286284
.map_err(StartMicrovmError::GuestMemory)?
@@ -299,7 +297,7 @@ pub fn build_microvm_for_boot(
299297
event_manager,
300298
guest_memory,
301299
None,
302-
track_dirty_pages,
300+
vm_resources.vm_config.track_dirty_pages,
303301
vm_resources.vm_config.vcpu_count,
304302
cpu_template.kvm_capabilities.clone(),
305303
)?;

src/vmm/src/resources.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,6 @@ impl VmResources {
234234
Ok(())
235235
}
236236

237-
/// Returns whether dirty page tracking is enabled or not.
238-
pub fn track_dirty_pages(&self) -> bool {
239-
self.vm_config.track_dirty_pages
240-
}
241-
242237
/// Add a custom CPU template to the VM resources
243238
/// to configure vCPUs.
244239
pub fn set_custom_cpu_template(&mut self, cpu_template: CustomCpuTemplate) {

src/vmm/src/rpc_interface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ impl RuntimeApiController {
755755
log_dev_preview_warning("Virtual machine snapshots", None);
756756

757757
if create_params.snapshot_type == SnapshotType::Diff
758-
&& !self.vm_resources.track_dirty_pages()
758+
&& !self.vm_resources.vm_config.track_dirty_pages
759759
{
760760
return Err(VmmActionError::NotSupported(
761761
"Diff snapshots are not allowed on uVMs with dirty page tracking disabled."

0 commit comments

Comments
 (0)