Flag guard virtual cpufreq support
The feature is guarded by the RELEASE_AVF_ENABLE_VIRT_CPUFREQ flag. In
Virtualization manager, --virt-cpufreq and --host-cpu-topology is only
passed to crosvm when launching a VM if this feature is enabled.
Bug: 322415363
Test: Builds
Change-Id: I35dca05b42323bdca4f5855bbfe991ba90bbb229
Signed-off-by: David Dai <davidai@google.com>
diff --git a/Android.bp b/Android.bp
index 54919d4..696a963 100644
--- a/Android.bp
+++ b/Android.bp
@@ -28,6 +28,7 @@
"release_avf_enable_multi_tenant_microdroid_vm",
"release_avf_enable_remote_attestation",
"release_avf_enable_vendor_modules",
+ "release_avf_enable_virt_cpufreq",
],
properties: [
"cfgs",
@@ -55,6 +56,9 @@
release_avf_enable_vendor_modules: {
cfgs: ["vendor_modules"],
},
+ release_avf_enable_virt_cpufreq: {
+ cfgs: ["virt_cpufreq"],
+ },
},
}
diff --git a/virtualizationmanager/src/crosvm.rs b/virtualizationmanager/src/crosvm.rs
index 4b3478e..fe8a587 100644
--- a/virtualizationmanager/src/crosvm.rs
+++ b/virtualizationmanager/src/crosvm.rs
@@ -810,8 +810,10 @@
}
if config.host_cpu_topology {
- // TODO(b/266664564): replace with --host-cpu-topology once available
- if let Some(cpus) = get_num_cpus() {
+ if cfg!(virt_cpufreq) {
+ command.arg("--host-cpu-topology");
+ command.arg("--virt-cpufreq");
+ } else if let Some(cpus) = get_num_cpus() {
command.arg("--cpus").arg(cpus.to_string());
} else {
bail!("Could not determine the number of CPUs in the system");