performance-metrics: Add vm_type param to new_guest

Update performance_test_new_guest() to accept a GuestVmType
parameter. When set to Confidential, configure the guest with
CVM-specific settings: vm_type, boot_timeout, and nested
virtualization disabled.

All callers pass GuestVmType::Regular to preserve existing
behavior.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
Muminul Islam
2026-04-01 18:47:50 -07:00
committed by Rob Bradford
parent 82a0dc7252
commit 938db39e26

View File

@@ -120,8 +120,14 @@ pub fn cleanup_tests() {
// private network. The default constructor "Guest::new()" does not work // private network. The default constructor "Guest::new()" does not work
// well, as we can easily create more than 256 VMs from repeating various // well, as we can easily create more than 256 VMs from repeating various
// performance tests dozens times in a single run. // performance tests dozens times in a single run.
fn performance_test_new_guest(disk_config: Box<dyn DiskConfig>) -> Guest { fn performance_test_new_guest(disk_config: Box<dyn DiskConfig>, vm_type: GuestVmType) -> Guest {
Guest::new_from_ip_range(disk_config, "172.19", 0) let mut guest = Guest::new_from_ip_range(disk_config, "172.19", 0);
if vm_type == GuestVmType::Confidential {
guest.vm_type = GuestVmType::Confidential;
guest.boot_timeout = DEFAULT_CVM_TCP_LISTENER_TIMEOUT;
guest.nested = false;
}
guest
} }
pub fn performance_net_throughput(control: &PerformanceTestControl) -> f64 { pub fn performance_net_throughput(control: &PerformanceTestControl) -> f64 {
@@ -129,7 +135,7 @@ pub fn performance_net_throughput(control: &PerformanceTestControl) -> f64 {
let (rx, bandwidth) = control.net_control.unwrap(); let (rx, bandwidth) = control.net_control.unwrap();
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
let guest = performance_test_new_guest(Box::new(focal)); let guest = performance_test_new_guest(Box::new(focal), GuestVmType::Regular);
let num_queues = control.num_queues.unwrap(); let num_queues = control.num_queues.unwrap();
let queue_size = control.queue_size.unwrap(); let queue_size = control.queue_size.unwrap();
@@ -170,7 +176,7 @@ pub fn performance_net_throughput(control: &PerformanceTestControl) -> f64 {
pub fn performance_net_latency(control: &PerformanceTestControl) -> f64 { pub fn performance_net_latency(control: &PerformanceTestControl) -> f64 {
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
let guest = performance_test_new_guest(Box::new(focal)); let guest = performance_test_new_guest(Box::new(focal), GuestVmType::Regular);
let num_queues = control.num_queues.unwrap(); let num_queues = control.num_queues.unwrap();
let queue_size = control.queue_size.unwrap(); let queue_size = control.queue_size.unwrap();
@@ -318,7 +324,7 @@ fn measure_boot_time(cmd: &mut GuestCommand, test_timeout: u32) -> Result<f64, E
pub fn performance_boot_time(control: &PerformanceTestControl) -> f64 { pub fn performance_boot_time(control: &PerformanceTestControl) -> f64 {
let r = std::panic::catch_unwind(|| { let r = std::panic::catch_unwind(|| {
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
let guest = performance_test_new_guest(Box::new(focal)); let guest = performance_test_new_guest(Box::new(focal), GuestVmType::Regular);
let mut cmd = GuestCommand::new(&guest); let mut cmd = GuestCommand::new(&guest);
let c = cmd let c = cmd
@@ -346,7 +352,7 @@ pub fn performance_boot_time(control: &PerformanceTestControl) -> f64 {
pub fn performance_boot_time_pmem(control: &PerformanceTestControl) -> f64 { pub fn performance_boot_time_pmem(control: &PerformanceTestControl) -> f64 {
let r = std::panic::catch_unwind(|| { let r = std::panic::catch_unwind(|| {
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
let guest = performance_test_new_guest(Box::new(focal)); let guest = performance_test_new_guest(Box::new(focal), GuestVmType::Regular);
let mut cmd = GuestCommand::new(&guest); let mut cmd = GuestCommand::new(&guest);
let c = cmd let c = cmd
.args([ .args([
@@ -387,7 +393,7 @@ pub fn performance_block_io(control: &PerformanceTestControl) -> f64 {
let test_file = block_control.test_file; let test_file = block_control.test_file;
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
let guest = performance_test_new_guest(Box::new(focal)); let guest = performance_test_new_guest(Box::new(focal), GuestVmType::Regular);
let api_socket = guest let api_socket = guest
.tmp_dir .tmp_dir
.as_path() .as_path()
@@ -529,7 +535,7 @@ fn measure_restore_time(
pub fn performance_restore_latency(control: &PerformanceTestControl) -> f64 { pub fn performance_restore_latency(control: &PerformanceTestControl) -> f64 {
let r = std::panic::catch_unwind(|| { let r = std::panic::catch_unwind(|| {
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
let guest = performance_test_new_guest(Box::new(focal)); let guest = performance_test_new_guest(Box::new(focal), GuestVmType::Regular);
let api_socket_source = String::from( let api_socket_source = String::from(
guest guest
.tmp_dir .tmp_dir