Use crosvm's --host-cpu-topology option
CL I03a37be0b68b93dc0fa6e84fd51ca3bdefbe6dde changed the client API to
only select between a small number of vCPU configurations. One of them
is to match the host CPU topology. So far this was implemented by
creating the same number of vCPUs as logical cores in the system. Now
that crosvm supports the '--host-cpu-topology' command line option on
all architectures, we can switch over to using it.
Bug: 266664564
Test: atest -p packages/modules/Virtualization:avf-presubmit
Change-Id: I0b31271ee62fc51acf6f9de2fccd4e449364d1a9
diff --git a/virtualizationmanager/src/atom.rs b/virtualizationmanager/src/atom.rs
index 567fce9..5c1f394 100644
--- a/virtualizationmanager/src/atom.rs
+++ b/virtualizationmanager/src/atom.rs
@@ -82,7 +82,7 @@
// Returns the number of CPUs configured in the host system.
// This matches how crosvm determines the number of logical cores.
// For telemetry purposes only.
-pub(crate) fn get_num_cpus() -> Option<usize> {
+fn get_num_cpus() -> Option<usize> {
// SAFETY - Only integer constants passed back and forth.
let ret = unsafe { libc::sysconf(libc::_SC_NPROCESSORS_CONF) };
if ret > 0 {
diff --git a/virtualizationmanager/src/crosvm.rs b/virtualizationmanager/src/crosvm.rs
index ea1146e..66efba9 100644
--- a/virtualizationmanager/src/crosvm.rs
+++ b/virtualizationmanager/src/crosvm.rs
@@ -15,7 +15,7 @@
//! Functions for running instances of `crosvm`.
use crate::aidl::{remove_temporary_files, Cid, VirtualMachineCallbacks};
-use crate::atom::{get_num_cpus, write_vm_exited_stats};
+use crate::atom::write_vm_exited_stats;
use anyhow::{anyhow, bail, Context, Error, Result};
use command_fds::CommandFdExt;
use lazy_static::lazy_static;
@@ -734,12 +734,7 @@
}
if config.host_cpu_topology {
- // TODO(b/266664564): replace with --host-cpu-topology once available
- 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");
- }
+ command.arg("--host-cpu-topology");
}
if !config.task_profiles.is_empty() {