Merge "No need to pass Strong, just a regular reference is fine."
diff --git a/vm/src/create_idsig.rs b/vm/src/create_idsig.rs
index a0d64d5..fe7cd82 100644
--- a/vm/src/create_idsig.rs
+++ b/vm/src/create_idsig.rs
@@ -15,14 +15,14 @@
//! Command to create or update an idsig for APK
use android_system_virtualizationservice::aidl::android::system::virtualizationservice::IVirtualizationService::IVirtualizationService;
-use android_system_virtualizationservice::binder::{ParcelFileDescriptor, Strong};
+use android_system_virtualizationservice::binder::ParcelFileDescriptor;
use anyhow::{Context, Error};
use std::fs::{File, OpenOptions};
use std::path::Path;
/// Creates or update the idsig file by digesting the input APK file.
pub fn command_create_idsig(
- service: Strong<dyn IVirtualizationService>,
+ service: &dyn IVirtualizationService,
apk: &Path,
idsig: &Path,
) -> Result<(), Error> {
diff --git a/vm/src/create_partition.rs b/vm/src/create_partition.rs
index 22f7bea..049c201 100644
--- a/vm/src/create_partition.rs
+++ b/vm/src/create_partition.rs
@@ -16,7 +16,7 @@
use android_system_virtualizationservice::aidl::android::system::virtualizationservice::IVirtualizationService::IVirtualizationService;
use android_system_virtualizationservice::aidl::android::system::virtualizationservice::PartitionType::PartitionType;
-use android_system_virtualizationservice::binder::{ParcelFileDescriptor, Strong};
+use android_system_virtualizationservice::binder::ParcelFileDescriptor;
use anyhow::{Context, Error};
use std::convert::TryInto;
use std::fs::OpenOptions;
@@ -24,7 +24,7 @@
/// Initialise an empty partition image of the given size to be used as a writable partition.
pub fn command_create_partition(
- service: Strong<dyn IVirtualizationService>,
+ service: &dyn IVirtualizationService,
image_path: &Path,
size: u64,
partition_type: PartitionType,
diff --git a/vm/src/main.rs b/vm/src/main.rs
index 8b438b4..705e38f 100644
--- a/vm/src/main.rs
+++ b/vm/src/main.rs
@@ -191,8 +191,9 @@
// We need to start the thread pool for Binder to work properly, especially link_to_death.
ProcessState::start_thread_pool();
- let service = wait_for_interface(VIRTUALIZATION_SERVICE_BINDER_SERVICE_IDENTIFIER)
- .context("Failed to find VirtualizationService")?;
+ let service: Strong<dyn IVirtualizationService> =
+ wait_for_interface(VIRTUALIZATION_SERVICE_BINDER_SERVICE_IDENTIFIER)
+ .context("Failed to find VirtualizationService")?;
match opt {
Opt::RunApp {
@@ -211,7 +212,7 @@
task_profiles,
extra_idsigs,
} => command_run_app(
- service,
+ service.as_ref(),
&apk,
&idsig,
&instance,
@@ -229,7 +230,7 @@
),
Opt::Run { config, daemonize, cpus, cpu_affinity, task_profiles, console, log } => {
command_run(
- service,
+ service.as_ref(),
&config,
daemonize,
console.as_deref(),
@@ -240,18 +241,18 @@
task_profiles,
)
}
- Opt::Stop { cid } => command_stop(service, cid),
- Opt::List => command_list(service),
+ Opt::Stop { cid } => command_stop(service.as_ref(), cid),
+ Opt::List => command_list(service.as_ref()),
Opt::Info => command_info(),
Opt::CreatePartition { path, size, partition_type } => {
- command_create_partition(service, &path, size, partition_type)
+ command_create_partition(service.as_ref(), &path, size, partition_type)
}
- Opt::CreateIdsig { apk, path } => command_create_idsig(service, &apk, &path),
+ Opt::CreateIdsig { apk, path } => command_create_idsig(service.as_ref(), &apk, &path),
}
}
/// Retrieve reference to a previously daemonized VM and stop it.
-fn command_stop(service: Strong<dyn IVirtualizationService>, cid: u32) -> Result<(), Error> {
+fn command_stop(service: &dyn IVirtualizationService, cid: u32) -> Result<(), Error> {
service
.debugDropVmRef(cid as i32)
.context("Failed to get VM from VirtualizationService")?
@@ -260,7 +261,7 @@
}
/// List the VMs currently running.
-fn command_list(service: Strong<dyn IVirtualizationService>) -> Result<(), Error> {
+fn command_list(service: &dyn IVirtualizationService) -> Result<(), Error> {
let vms = service.debugListVms().context("Failed to get list of VMs")?;
println!("Running VMs: {:#?}", vms);
Ok(())
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() },