Clean up instance tracking

We used to hold a Weak<CompOsInstance>, so that we could allow clients
to retrieve the current running instance. But we haven't supported
that since commit 616f822f8a4186f9d29edc6a75cf9d31350ecc7d, and it
confuses the ownership semantics.

We still need to track whether an instance is running, but we can do
that via a separate Arc<()> that is kept alive by the instance.

Bug: 236581575
Test: compos_cmd test-compile
Test: Try to start a second instance, observe failure
Change-Id: Id02a831b249f6432b22741dbf5a5dc3919c3df03
diff --git a/compos/composd/src/instance_starter.rs b/compos/composd/src/instance_starter.rs
index e51db13..111c719 100644
--- a/compos/composd/src/instance_starter.rs
+++ b/compos/composd/src/instance_starter.rs
@@ -29,6 +29,7 @@
 use log::info;
 use std::fs;
 use std::path::{Path, PathBuf};
+use std::sync::Arc;
 
 pub struct CompOsInstance {
     service: Strong<dyn ICompOsService>,
@@ -36,6 +37,8 @@
     vm_instance: ComposClient,
     #[allow(dead_code)] // Keeps composd process alive
     lazy_service_guard: LazyServiceGuard,
+    // Keep this alive as long as we are
+    instance_tracker: Arc<()>,
 }
 
 impl CompOsInstance {
@@ -43,7 +46,13 @@
         self.service.clone()
     }
 
-    // Attempt to shut down the VM cleanly, giving time for any relevant logs to be written.
+    /// Returns an Arc that this instance holds a strong reference to as long as it exists. This
+    /// can be used to determine when the instance has been dropped.
+    pub fn get_instance_tracker(&self) -> &Arc<()> {
+        &self.instance_tracker
+    }
+
+    /// 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
@@ -122,7 +131,12 @@
         )
         .context("Starting VM")?;
         let service = vm_instance.connect_service().context("Connecting to CompOS")?;
-        Ok(CompOsInstance { vm_instance, service, lazy_service_guard: Default::default() })
+        Ok(CompOsInstance {
+            vm_instance,
+            service,
+            lazy_service_guard: Default::default(),
+            instance_tracker: Default::default(),
+        })
     }
 
     fn create_instance_image(