Initiailize assumed BOOTCLASSPATH and DEX2OATBOOTCLASSPATH
This change simply tells the VM to use Android's BOTTCLASSPATH and
DEX2OATBOOTCLASSPATH. This won't work with staged APEXes, and we need to
fix how the initialization is done.
For now, having these environment variables set unblock a few changes.
Bug: 198211396
Test: With local changes that fail without these env variables,
ComposHostTestCases passed with this change.
Change-Id: If4ccb9fb2dbea0658b6667878c848bb51df43cde
diff --git a/compos/composd/src/instance_starter.rs b/compos/composd/src/instance_starter.rs
index 1751d35..63aefb8 100644
--- a/compos/composd/src/instance_starter.rs
+++ b/compos/composd/src/instance_starter.rs
@@ -28,6 +28,7 @@
COMPOS_DATA_ROOT, INSTANCE_IMAGE_FILE, PRIVATE_KEY_BLOB_FILE, PUBLIC_KEY_FILE,
};
use log::{info, warn};
+use std::env;
use std::fs;
use std::path::{Path, PathBuf};
@@ -100,7 +101,7 @@
// current set of APEXes) and the key blob can be successfully decrypted by the VM. So the
// files have not been tampered with and we're good to go.
- service.initializeSigningKey(&key_blob).context("Loading signing key")?;
+ Self::initialize_service(service, &key_blob)?;
Ok(compos_instance)
}
@@ -129,13 +130,25 @@
}
fs::write(&self.public_key, &rsa_public_key).context("Writing public key")?;
- // We don't need to verify the key, since we just generated it and have it in memory.
+ // Unlike when starting an existing instance, we don't need to verify the key, since we
+ // just generated it and have it in memory.
- service.initializeSigningKey(&key_data.keyBlob).context("Loading signing key")?;
+ Self::initialize_service(service, &key_data.keyBlob)?;
Ok(compos_instance)
}
+ fn initialize_service(service: &Strong<dyn ICompOsService>, key_blob: &[u8]) -> Result<()> {
+ // Key blob is assumed to be verified/trusted.
+ service.initializeSigningKey(key_blob).context("Loading signing key")?;
+
+ // TODO(198211396): Implement correctly.
+ service
+ .initializeClasspaths(&env::var("BOOTCLASSPATH")?, &env::var("DEX2OATBOOTCLASSPATH")?)
+ .context("Initializing *CLASSPATH")?;
+ Ok(())
+ }
+
fn start_vm(&self) -> Result<CompOsInstance> {
let instance_image = fs::OpenOptions::new()
.read(true)