Skip to content

Conversation

@dpaliulis-msft
Copy link
Contributor

@dpaliulis-msft dpaliulis-msft commented Sep 11, 2025

Description:
This PR updates the VMM test pipeline to evaluate VTL2 memory usage. This is done to track changes in memory usage and produce a failed test for builds that result in an increase in memory usage beyond reasonable variance.

Changes

  • Implement module to collect all relevant VTL2 memory usage information
  • Add tests for VMs with 2VPs and 64VPs with 16GB VTL0 memory across TDX, SNP, and ARM architectures
  • Add test for VMs with 2VPs and 32VPs with 16GB VTL0 memory for GP x64 VMs
  • Log memory usage information as JSON
  • Produce a failed test for builds that result in memory usage that exceeds reasonable variance from baseline values

@dpaliulis-msft dpaliulis-msft requested review from a team as code owners September 11, 2025 21:13
Copilot AI review requested due to automatic review settings September 11, 2025 21:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds VTL2 memory usage validation tests to the VMM test pipeline to track memory consumption changes and detect builds that exceed acceptable memory usage thresholds.

Key Changes

  • Added a new MemStat module to collect VTL2 memory usage information from processes like underhill_init, openvmm_hcl, and underhill_vm
  • Implemented four new test functions that evaluate memory usage across different VM configurations (2VP and 64VP with 16GB VTL0 memory)
  • Added JSON logging of memory statistics for baseline comparison and monitoring

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 12 comments.

File Description
petri/src/memstat.rs New module implementing memory statistics collection from VTL2 processes via /proc filesystem
petri/src/lib.rs Exposed the new memstat module as public API
vmm_tests/vmm_tests/Cargo.toml Added serde_json dependency for JSON serialization of memory statistics
vmm_tests/vmm_tests/tests/tests/multiarch.rs Added four new test functions for memory validation across different VM configurations and architectures

Comment on lines 30 to 35
pub fn clone(&self) -> PerProcessMemstat {
PerProcessMemstat {
smaps_rollup: self.smaps_rollup.clone(),
statm: self.statm.clone(),
}
}
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual clone implementation is unnecessary. Derive Clone trait instead for better maintainability and consistency.

Copilot uses AI. Check for mistakes.
Comment on lines 93 to 95
underhill_init: per_process_data["underhill_init"].clone(),
openvmm_hcl: per_process_data["openvmm_hcl"].clone(),
underhill_vm: per_process_data["underhill_vm"].clone(),
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using bracket notation for HashMap access will panic if the expected process names are not found. Use .get() with proper error handling or .unwrap_or_default() to prevent panics.

Copilot uses AI. Check for mistakes.
Comment on lines 108 to 110
let field = split_line[field_col].trim_matches(':').to_string();
let value: u64 = split_line[value_col].parse().unwrap();
parsed_data.insert(field, value);
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array indexing without bounds checking will panic if the line doesn't have enough columns. Add bounds checking before accessing array elements.

Suggested change
let field = split_line[field_col].trim_matches(':').to_string();
let value: u64 = split_line[value_col].parse().unwrap();
parsed_data.insert(field, value);
if split_line.len() > field_col && split_line.len() > value_col {
let field = split_line[field_col].trim_matches(':').to_string();
let value: u64 = split_line[value_col].parse().unwrap();
parsed_data.insert(field, value);
}

Copilot uses AI. Check for mistakes.
use serde::Serialize;
use std::collections::HashMap;

#[expect(missing_docs)]
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Public structs and methods should have proper documentation instead of using #[expect(missing_docs)]. Add doc comments explaining the purpose and fields of each struct.

Copilot uses AI. Check for mistakes.
pub statm: HashMap<String, u64>,
}

#[expect(missing_docs)]
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Public structs and methods should have proper documentation instead of using #[expect(missing_docs)]. Add doc comments explaining the purpose and fields of each struct.

Copilot uses AI. Check for mistakes.

vm.send_enlightened_shutdown(ShutdownKind::Shutdown).await?;
vm.wait_for_clean_teardown().await?;
assert!(true);
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert!(true) is meaningless and should be removed. These assertions provide no validation and add unnecessary code.

Suggested change
assert!(true);

Copilot uses AI. Check for mistakes.

vm.send_enlightened_shutdown(ShutdownKind::Shutdown).await?;
vm.wait_for_clean_teardown().await?;
assert!(true);
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert!(true) is meaningless and should be removed. These assertions provide no validation and add unnecessary code.

Copilot uses AI. Check for mistakes.

agent.power_off().await?;
vm.wait_for_teardown().await?;
assert!(true);
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert!(true) is meaningless and should be removed. These assertions provide no validation and add unnecessary code.

Suggested change
assert!(true);

Copilot uses AI. Check for mistakes.

agent.power_off().await?;
vm.wait_for_teardown().await?;
assert!(true);
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert!(true) is meaningless and should be removed. These assertions provide no validation and add unnecessary code.

Suggested change
assert!(true);

Copilot uses AI. Check for mistakes.
let now = std::time::Instant::now();
let wait_time = Duration::from_secs(60);
std::thread::sleep(wait_time);
assert!(now.elapsed() >= wait_time);
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertion after sleep is redundant since sleep guarantees the wait time has elapsed. This check adds no value and should be removed.

Suggested change
assert!(now.elapsed() >= wait_time);

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

@github-actions
Copy link

@github-actions
Copy link

@github-actions
Copy link

@github-actions
Copy link

@github-actions
Copy link

@github-actions
Copy link

workspace = true

[dependencies]
serde_json.workspace = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this up to dev-dependencies with everything else.

openvmm_openhcl_uefi_x64(vhd(ubuntu_2204_server_x64))
)]
async fn validate_mnf_usage_in_guest(
async fn validate_mnf_usage_in_guest_reboot(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the name change?

})
.run_without_agent()
.await?;
std::thread::sleep(Duration::from_secs(60));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't ever need to sleep in a test.

@github-actions
Copy link

github-actions bot commented Oct 2, 2025

@github-actions
Copy link

github-actions bot commented Oct 2, 2025

@dpaliulis-msft dpaliulis-msft force-pushed the user/dpaliulis/vmm_tests-memory_validation branch from f2ad497 to 34081db Compare October 3, 2025 00:34
@github-actions
Copy link

github-actions bot commented Oct 3, 2025

@github-actions
Copy link

github-actions bot commented Oct 3, 2025

smalis-msft
smalis-msft previously approved these changes Oct 3, 2025
@github-actions
Copy link

github-actions bot commented Oct 4, 2025

@dpaliulis-msft dpaliulis-msft merged commit 8523232 into microsoft:main Oct 6, 2025
29 checks passed
andyplank-msft pushed a commit to andyplank-msft/openvmm that referenced this pull request Nov 4, 2025
…#1995)

Description:
This PR updates the VMM test pipeline to evaluate VTL2 memory usage.
This is done to track changes in memory usage and produce a failed test
for builds that result in an increase in memory usage beyond reasonable
variance.

**Changes**
- Implement module to collect all relevant VTL2 memory usage information
- Add tests for VMs with 2VPs and 64VPs with 16GB VTL0 memory across
TDX, SNP, and ARM architectures
- Add test for VMs with 2VPs and 32VPs with 16GB VTL0 memory for GP x64
VMs
- Log memory usage information as JSON
- Produce a failed test for builds that result in memory usage that
exceeds reasonable variance from baseline values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants