Add instance creation to composd.

At startup we validate the files needed for the current instance exist
and are valid; if anything goes wrong we re-create them.

Bug: 186126194
Test: Manual, via composd_cmd.
Change-Id: Iaf19a74df14a91436c4cb4435f0286fa09307db8
diff --git a/compos/common/compos_client.rs b/compos/common/compos_client.rs
index 9e95ed0..e68deb8 100644
--- a/compos/common/compos_client.rs
+++ b/compos/common/compos_client.rs
@@ -55,6 +55,13 @@
 }
 
 impl VmInstance {
+    /// Return a new connection to the Virtualization Service binder interface. This will start the
+    /// service if necessary.
+    pub fn connect_to_virtualization_service() -> Result<Strong<dyn IVirtualizationService>> {
+        wait_for_interface::<dyn IVirtualizationService>("android.system.virtualizationservice")
+            .context("Failed to find VirtualizationService")
+    }
+
     /// Start a new CompOS VM instance using the specified instance image file.
     pub fn start(instance_image: &Path) -> Result<VmInstance> {
         let instance_image =
@@ -84,10 +91,7 @@
             ..Default::default()
         });
 
-        let service = wait_for_interface::<dyn IVirtualizationService>(
-            "android.system.virtualizationservice",
-        )
-        .context("Failed to find VirtualizationService")?;
+        let service = Self::connect_to_virtualization_service()?;
 
         let vm = service.createVm(&config, Some(&log_fd)).context("Failed to create VM")?;
         let vm_state = Arc::new(VmStateMonitor::default());