Allow the test CompOS VM to use all CPUs by default

Note that this doesn't change verify_key (so it always uses 1 vCPU)
because the system property is specific to compilation.

For unknown reason, odrefresh takes longer when running with multiple
vCPU in the VM. See b/216557997.

Bug: 197358423
Test: Run `composd_cmd test-compile` on oriole. See 8 cpu in /proc/cpuinfo
Change-Id: Ie1a0bd4db3f33fef20d186af1718064f7094725b
diff --git a/compos/composd/src/instance_manager.rs b/compos/composd/src/instance_manager.rs
index e8c1d9a..2f15cb5 100644
--- a/compos/composd/src/instance_manager.rs
+++ b/compos/composd/src/instance_manager.rs
@@ -43,22 +43,14 @@
     }
 
     pub fn start_pending_instance(&self) -> Result<Arc<CompOsInstance>> {
-        let config_path = Some(PREFER_STAGED_VM_CONFIG_PATH.to_owned());
-        let mut vm_parameters = VmParameters { config_path, ..Default::default() };
-        vm_parameters.cpus = match system_properties::read(DEX2OAT_THREADS_PROP_NAME) {
-            Ok(s) => Some(NonZeroU32::from_str(&s)?),
-            Err(_) => {
-                // dex2oat uses all CPUs by default. To match the behavior, give the VM all CPUs by
-                // default.
-                NonZeroU32::new(num_cpus::get() as u32)
-            }
-        };
-        vm_parameters.cpu_set = system_properties::read(DEX2OAT_CPU_SET_PROP_NAME).ok();
+        let mut vm_parameters = new_vm_parameters()?;
+        vm_parameters.config_path = Some(PREFER_STAGED_VM_CONFIG_PATH.to_owned());
         self.start_instance(PENDING_INSTANCE_DIR, vm_parameters)
     }
 
     pub fn start_test_instance(&self) -> Result<Arc<CompOsInstance>> {
-        let vm_parameters = VmParameters { debug_mode: true, ..Default::default() };
+        let mut vm_parameters = new_vm_parameters()?;
+        vm_parameters.debug_mode = true;
         self.start_instance(TEST_INSTANCE_DIR, vm_parameters)
     }
 
@@ -90,6 +82,19 @@
     }
 }
 
+fn new_vm_parameters() -> Result<VmParameters> {
+    let cpus = match system_properties::read(DEX2OAT_THREADS_PROP_NAME) {
+        Ok(s) => Some(NonZeroU32::from_str(&s)?),
+        Err(_) => {
+            // dex2oat uses all CPUs by default. To match the behavior, give the VM all CPUs by
+            // default.
+            NonZeroU32::new(num_cpus::get() as u32)
+        }
+    };
+    let cpu_set = system_properties::read(DEX2OAT_CPU_SET_PROP_NAME).ok();
+    Ok(VmParameters { cpus, cpu_set, ..Default::default() })
+}
+
 // Ensures we only run one instance at a time.
 // Valid states:
 // Starting: is_starting is true, running_instance is None.