No need to pass Strong, just a regular reference is fine.
Test: m vm
Change-Id: I8dc18a5f843cb528782dd6ce961b3943492572df
diff --git a/vm/src/run.rs b/vm/src/run.rs
index 2886b87..2ae2c95 100644
--- a/vm/src/run.rs
+++ b/vm/src/run.rs
@@ -26,9 +26,9 @@
VirtualMachineState::VirtualMachineState,
};
use android_system_virtualizationservice::binder::{
- BinderFeatures, DeathRecipient, IBinder, ParcelFileDescriptor, Strong,
+ BinderFeatures, DeathRecipient, IBinder, Interface, ParcelFileDescriptor,
+ Result as BinderResult,
};
-use android_system_virtualizationservice::binder::{Interface, Result as BinderResult};
use anyhow::{bail, Context, Error};
use microdroid_payload_config::VmPayloadConfig;
use std::fs::File;
@@ -41,7 +41,7 @@
/// Run a VM from the given APK, idsig, and config.
#[allow(clippy::too_many_arguments)]
pub fn command_run_app(
- service: Strong<dyn IVirtualizationService>,
+ service: &dyn IVirtualizationService,
apk: &Path,
idsig: &Path,
instance: &Path,
@@ -85,7 +85,7 @@
if !instance.exists() {
const INSTANCE_FILE_SIZE: u64 = 10 * 1024 * 1024;
command_create_partition(
- service.clone(),
+ service,
instance,
INSTANCE_FILE_SIZE,
PartitionType::ANDROID_VM_INSTANCE,
@@ -121,7 +121,7 @@
/// Run a VM from the given configuration file.
#[allow(clippy::too_many_arguments)]
pub fn command_run(
- service: Strong<dyn IVirtualizationService>,
+ service: &dyn IVirtualizationService,
config_path: &Path,
daemonize: bool,
console_path: Option<&Path>,
@@ -165,7 +165,7 @@
}
fn run(
- service: Strong<dyn IVirtualizationService>,
+ service: &dyn IVirtualizationService,
config: &VirtualMachineConfig,
config_path: &str,
daemonize: bool,
@@ -213,12 +213,12 @@
} else {
// Wait until the VM or VirtualizationService dies. If we just returned immediately then the
// IVirtualMachine Binder object would be dropped and the VM would be killed.
- wait_for_vm(vm)
+ wait_for_vm(vm.as_ref())
}
}
/// Wait until the given VM or the VirtualizationService itself dies.
-fn wait_for_vm(vm: Strong<dyn IVirtualMachine>) -> Result<(), Error> {
+fn wait_for_vm(vm: &dyn IVirtualMachine) -> Result<(), Error> {
let dead = AtomicFlag::default();
let callback = BnVirtualMachineCallback::new_binder(
VirtualMachineCallback { dead: dead.clone() },