Run VirtualMachineService only for Microdroid
Other VMs don't (actually shouldn't) make use of it. There's no need to
run the service.
Bug: 381124535
Test: N/A
Change-Id: Icfe96573a5bd178b01de4752080ece10d7f5d30c
diff --git a/android/virtmgr/src/crosvm.rs b/android/virtmgr/src/crosvm.rs
index 46f4e80..1ccabec 100644
--- a/android/virtmgr/src/crosvm.rs
+++ b/android/virtmgr/src/crosvm.rs
@@ -360,12 +360,15 @@
#[allow(dead_code)] // Keeps the global context alive
pub(crate) global_context: Strong<dyn IGlobalVmContext>,
#[allow(dead_code)] // Keeps the server alive
- vm_server: RpcServer,
+ vm_server: Option<RpcServer>,
}
impl VmContext {
/// Construct new VmContext.
- pub fn new(global_context: Strong<dyn IGlobalVmContext>, vm_server: RpcServer) -> VmContext {
+ pub fn new(
+ global_context: Strong<dyn IGlobalVmContext>,
+ vm_server: Option<RpcServer>,
+ ) -> VmContext {
VmContext { global_context, vm_server }
}
}
@@ -655,7 +658,9 @@
// Now that the VM has been killed, shut down the VirtualMachineService
// server to eagerly free up the server threads.
- self.vm_context.vm_server.shutdown()?;
+ if let Some(vm_server) = &self.vm_context.vm_server {
+ vm_server.shutdown()?;
+ }
Ok(())
}