Shut down CompOS VM after compilation completes
Add a method to CompOsInstance to consume the instance and shut it
down cleanly, allowing logs to be written. Call this when compilation
ends, before calling back to our client (since they might then drop
their reference to us, which could tear everything down prematurely).
I also created a method to combind the calls to quit() and
wait_for_shutdown() to reduce duplication.
I also increased the shutdown timeout, since my initial value doesn't
seem to be enough for CompOS (see b/236588647#comment38).
Bug: 236581575
Test: composd_cmd test-compile, observe logs
Change-Id: I34a227db0e377cb9aded57461379e17d0574ea0c
diff --git a/compos/composd/src/instance_starter.rs b/compos/composd/src/instance_starter.rs
index 6e6253e..e51db13 100644
--- a/compos/composd/src/instance_starter.rs
+++ b/compos/composd/src/instance_starter.rs
@@ -42,6 +42,14 @@
pub fn get_service(&self) -> Strong<dyn ICompOsService> {
self.service.clone()
}
+
+ // Attempt to shut down the VM cleanly, giving time for any relevant logs to be written.
+ pub fn shutdown(self) -> LazyServiceGuard {
+ self.vm_instance.shutdown(self.service);
+ // Return the guard to the caller, since we might be terminated at any point after it is
+ // dropped, and there might still be things to do.
+ self.lazy_service_guard
+ }
}
pub struct InstanceStarter {