Respect dalvik.vm.boot-dex2oat-[threads|cpu-set]

The properties on the host side are now used to configure the number of
vCPUs and their affinity to the host CPU for the compos VM. Then inside
the VM, the system property is set to the number of vCPU so that the
concurrency level of dex2oat inside the VM is controlled by the
host-side system property.

Bug : 197358423
Test: adb shell setprop dalvik.vm.boot-dex2oat-thread 2
adb shell setprop dalvik.vm.boot-dex2oat-cpu-set 0,1
adb shell /apex/com.android.compos/bin/composd_cmd
staged-apex-compile

Crosvm is run with --cpus 2 and --cpu-affinity 0,1
`top` shows that (host) CPU usage is over 100%

Change-Id: I4239a6e1656a9fb852fdd7db3e0ba716290ea5bc
diff --git a/compos/composd/src/instance_manager.rs b/compos/composd/src/instance_manager.rs
index 24ae576..4fc4ad1 100644
--- a/compos/composd/src/instance_manager.rs
+++ b/compos/composd/src/instance_manager.rs
@@ -23,7 +23,13 @@
 use compos_aidl_interface::aidl::com::android::compos::ICompOsService::ICompOsService;
 use compos_aidl_interface::binder::Strong;
 use compos_common::compos_client::VmParameters;
-use compos_common::{PENDING_INSTANCE_DIR, PREFER_STAGED_VM_CONFIG_PATH, TEST_INSTANCE_DIR};
+use compos_common::{
+    DEX2OAT_CPU_SET_PROP_NAME, DEX2OAT_THREADS_PROP_NAME, PENDING_INSTANCE_DIR,
+    PREFER_STAGED_VM_CONFIG_PATH, TEST_INSTANCE_DIR,
+};
+use rustutils::system_properties;
+use std::num::NonZeroU32;
+use std::str::FromStr;
 use std::sync::{Arc, Mutex, Weak};
 use virtualizationservice::IVirtualizationService::IVirtualizationService;
 
@@ -45,7 +51,12 @@
 
     pub fn start_pending_instance(&self) -> Result<Arc<CompOsInstance>> {
         let config_path = Some(PREFER_STAGED_VM_CONFIG_PATH.to_owned());
-        let vm_parameters = VmParameters { config_path, ..Default::default() };
+        let mut vm_parameters = VmParameters { config_path, ..Default::default() };
+        vm_parameters.cpus = NonZeroU32::from_str(
+            &system_properties::read(DEX2OAT_THREADS_PROP_NAME).unwrap_or_default(),
+        )
+        .ok();
+        vm_parameters.cpu_set = system_properties::read(DEX2OAT_CPU_SET_PROP_NAME).ok();
         self.start_instance(PENDING_INSTANCE_DIR, vm_parameters)
     }