Use Strong<> for Rust AIDL interfaces
Switch the Rust types of AIDL interfaces from e.g.
&dyn IVirtualMachine to &Strong<dyn IVirtualMachine>.
Bug: 182890877
Test: m
Change-Id: I3db33caff9b4b7822ad117d3568c665c630a5243
diff --git a/virtmanager/src/aidl.rs b/virtmanager/src/aidl.rs
index 98af714..bc3ea1a 100644
--- a/virtmanager/src/aidl.rs
+++ b/virtmanager/src/aidl.rs
@@ -17,7 +17,6 @@
use crate::config::VmConfig;
use crate::crosvm::VmInstance;
use crate::{Cid, FIRST_GUEST_CID};
-use ::binder::FromIBinder; // TODO(dbrazdil): remove once b/182890877 is fixed
use android_system_virtmanager::aidl::android::system::virtmanager::IVirtManager::IVirtManager;
use android_system_virtmanager::aidl::android::system::virtmanager::IVirtualMachine::{
BnVirtualMachine, IVirtualMachine,
@@ -107,16 +106,13 @@
/// Hold a strong reference to a VM in Virt Manager. This method is only intended for debug
/// purposes, and as such is only permitted from the shell user.
- fn debugHoldVmRef(&self, vmref: &dyn IVirtualMachine) -> binder::Result<()> {
+ fn debugHoldVmRef(&self, vmref: &Strong<dyn IVirtualMachine>) -> binder::Result<()> {
if !debug_access_allowed() {
return Err(StatusCode::PERMISSION_DENIED.into());
}
- // Workaround for b/182890877.
- let vm: Strong<dyn IVirtualMachine> = FromIBinder::try_from(vmref.as_binder()).unwrap();
-
let state = &mut *self.state.lock().unwrap();
- state.debug_hold_vm(vm);
+ state.debug_hold_vm(vmref.clone());
Ok(())
}
diff --git a/vm/src/main.rs b/vm/src/main.rs
index 6c1052f..f47d9e8 100644
--- a/vm/src/main.rs
+++ b/vm/src/main.rs
@@ -89,7 +89,7 @@
if daemonize {
// Pass the VM reference back to Virt Manager and have it hold it in the background.
- virt_manager.debugHoldVmRef(&*vm).context("Failed to pass VM to Virt Manager")
+ virt_manager.debugHoldVmRef(&vm).context("Failed to pass VM to Virt Manager")
} else {
// Wait until the VM dies. If we just returned immediately then the IVirtualMachine Binder
// object would be dropped and the VM would be killed.