add option for custom vCPU count

Only supported by VirtualMachineRawConfig.

It has been observed that >1 vCPU hurts performance in some cases when
not also setting the CPU affinities and performing other tweaks, as done
by MATCH_HOST, so we avoided adding this before. However, there are
probably use cases where it is the best option and we've been explicitly
asked by partners to add it.

Bug: 381281047
Test: m
Change-Id: Ic22c747d064e70505398eb438a210ef42b5d75e1
diff --git a/android/virtmgr/src/aidl.rs b/android/virtmgr/src/aidl.rs
index 79c7d81..15a80a6 100644
--- a/android/virtmgr/src/aidl.rs
+++ b/android/virtmgr/src/aidl.rs
@@ -653,6 +653,14 @@
         let (cpus, host_cpu_topology) = match config.cpuTopology {
             CpuTopology::MATCH_HOST => (None, true),
             CpuTopology::ONE_CPU => (NonZeroU32::new(1), false),
+            CpuTopology::CUSTOM => (
+                NonZeroU32::new(
+                    u32::try_from(config.customVcpuCount)
+                        .context("bad customVcpuCount")
+                        .or_binder_exception(ExceptionCode::ILLEGAL_ARGUMENT)?,
+                ),
+                false,
+            ),
             val => {
                 return Err(anyhow!("Failed to parse CPU topology value {:?}", val))
                     .with_log()
@@ -1228,6 +1236,9 @@
     vm_config.name.clone_from(&config.name);
     vm_config.protectedVm = config.protectedVm;
     vm_config.cpuTopology = config.cpuTopology;
+    if config.cpuTopology == CpuTopology::CUSTOM {
+        bail!("AppConfig doesn't support CpuTopology::CUSTOM");
+    }
     vm_config.hugePages = config.hugePages || vm_payload_config.hugepages;
     vm_config.boostUclamp = config.boostUclamp;