Merge "Remove support for --daemonize"
diff --git a/virtualizationservice/aidl/android/system/virtualizationservice/IVirtualizationService.aidl b/virtualizationservice/aidl/android/system/virtualizationservice/IVirtualizationService.aidl
index e417ec4..fc4c9e7 100644
--- a/virtualizationservice/aidl/android/system/virtualizationservice/IVirtualizationService.aidl
+++ b/virtualizationservice/aidl/android/system/virtualizationservice/IVirtualizationService.aidl
@@ -53,17 +53,4 @@
* and as such is only permitted from the shell user.
*/
VirtualMachineDebugInfo[] debugListVms();
-
- /**
- * Hold a strong reference to a VM in VirtualizationService. This method is only intended for
- * debug purposes, and as such is only permitted from the shell user.
- */
- void debugHoldVmRef(IVirtualMachine vm);
-
- /**
- * Drop reference to a VM that is being held by VirtualizationService. Returns the reference if
- * VM was found and null otherwise. This method is only intended for debug purposes, and as such
- * is only permitted from the shell user.
- */
- @nullable IVirtualMachine debugDropVmRef(int cid);
}
diff --git a/virtualizationservice/src/aidl.rs b/virtualizationservice/src/aidl.rs
index 1c82155..374b90f 100644
--- a/virtualizationservice/src/aidl.rs
+++ b/virtualizationservice/src/aidl.rs
@@ -502,26 +502,6 @@
check_debug_access()?;
GLOBAL_SERVICE.debugListVms()
}
-
- /// Hold a strong reference to a VM in VirtualizationService. This method is only intended for
- /// debug purposes, and as such is only permitted from the shell user.
- fn debugHoldVmRef(&self, vmref: &Strong<dyn IVirtualMachine>) -> binder::Result<()> {
- check_debug_access()?;
-
- let state = &mut *self.state.lock().unwrap();
- state.debug_hold_vm(vmref.clone());
- Ok(())
- }
-
- /// Drop reference to a VM that is being held by VirtualizationService. Returns the reference if
- /// the VM was found and None otherwise. This method is only intended for debug purposes, and as
- /// such is only permitted from the shell user.
- fn debugDropVmRef(&self, cid: i32) -> binder::Result<Option<Strong<dyn IVirtualMachine>>> {
- check_debug_access()?;
-
- let state = &mut *self.state.lock().unwrap();
- Ok(state.debug_drop_vm(cid))
- }
}
fn handle_stream_connection_tombstoned() -> Result<()> {
@@ -1210,10 +1190,6 @@
/// Binder client are dropped the weak reference here will become invalid, and will be removed
/// from the list opportunistically the next time `add_vm` is called.
vms: Vec<Weak<VmInstance>>,
-
- /// Vector of strong VM references held on behalf of users that cannot hold them themselves.
- /// This is only used for debugging purposes.
- debug_held_vms: Vec<Strong<dyn IVirtualMachine>>,
}
impl State {
@@ -1236,18 +1212,6 @@
fn get_vm(&self, cid: Cid) -> Option<Arc<VmInstance>> {
self.vms().into_iter().find(|vm| vm.cid == cid)
}
-
- /// Store a strong VM reference.
- fn debug_hold_vm(&mut self, vm: Strong<dyn IVirtualMachine>) {
- self.debug_held_vms.push(vm);
- }
-
- /// Retrieve and remove a strong VM reference.
- fn debug_drop_vm(&mut self, cid: i32) -> Option<Strong<dyn IVirtualMachine>> {
- let pos = self.debug_held_vms.iter().position(|vm| vm.getCid() == Ok(cid))?;
- let vm = self.debug_held_vms.swap_remove(pos);
- Some(vm)
- }
}
/// Gets the `VirtualMachineState` of the given `VmInstance`.
diff --git a/vm/src/main.rs b/vm/src/main.rs
index bfc7920..ea744f7 100644
--- a/vm/src/main.rs
+++ b/vm/src/main.rs
@@ -60,10 +60,6 @@
#[clap(long)]
name: Option<String>,
- /// Detach VM from the terminal and run in the background
- #[clap(short, long)]
- daemonize: bool,
-
/// Path to the file backing the storage.
/// Created if the option is used but the path does not exist in the device.
#[clap(long)]
@@ -119,10 +115,6 @@
#[clap(long)]
name: Option<String>,
- /// Detach VM from the terminal and run in the background
- #[clap(short, long)]
- daemonize: bool,
-
/// Path to the file backing the storage.
/// Created if the option is used but the path does not exist in the device.
#[clap(long)]
@@ -171,10 +163,6 @@
#[clap(long)]
name: Option<String>,
- /// Detach VM from the terminal and run in the background
- #[clap(short, long)]
- daemonize: bool,
-
/// Number of vCPUs in the VM. If unspecified, defaults to 1.
#[clap(long)]
cpus: Option<u32>,
@@ -191,11 +179,6 @@
#[clap(long)]
log: Option<PathBuf>,
},
- /// Stop a virtual machine running in the background
- Stop {
- /// CID of the virtual machine
- cid: u32,
- },
/// List running virtual machines
List,
/// Print information about virtual machine support
@@ -260,7 +243,6 @@
storage_size,
config_path,
payload_binary_name,
- daemonize,
console,
log,
debug,
@@ -279,7 +261,6 @@
storage_size,
config_path,
payload_binary_name,
- daemonize,
console.as_deref(),
log.as_deref(),
debug,
@@ -294,7 +275,6 @@
work_dir,
storage,
storage_size,
- daemonize,
console,
log,
debug,
@@ -308,7 +288,6 @@
work_dir,
storage.as_deref(),
storage_size,
- daemonize,
console.as_deref(),
log.as_deref(),
debug,
@@ -317,12 +296,11 @@
cpus,
task_profiles,
),
- Opt::Run { name, config, daemonize, cpus, task_profiles, console, log } => {
+ Opt::Run { name, config, cpus, task_profiles, console, log } => {
command_run(
name,
service.as_ref(),
&config,
- daemonize,
console.as_deref(),
log.as_deref(),
/* mem */ None,
@@ -330,7 +308,6 @@
task_profiles,
)
}
- 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 } => {
@@ -340,15 +317,6 @@
}
}
-/// Retrieve reference to a previously daemonized VM and stop it.
-fn command_stop(service: &dyn IVirtualizationService, cid: u32) -> Result<(), Error> {
- service
- .debugDropVmRef(cid as i32)
- .context("Failed to get VM from VirtualizationService")?
- .context("CID does not correspond to a running background VM")?;
- Ok(())
-}
-
/// List the VMs currently running.
fn command_list(service: &dyn IVirtualizationService) -> Result<(), Error> {
let vms = service.debugListVms().context("Failed to get list of VMs")?;
diff --git a/vm/src/run.rs b/vm/src/run.rs
index b99328a..6c21dbc 100644
--- a/vm/src/run.rs
+++ b/vm/src/run.rs
@@ -49,7 +49,6 @@
storage_size: Option<u64>,
config_path: Option<String>,
payload_binary_name: Option<String>,
- daemonize: bool,
console_path: Option<&Path>,
log_path: Option<&Path>,
debug_level: DebugLevel,
@@ -145,7 +144,7 @@
numCpus: cpus.unwrap_or(1) as i32,
taskProfiles: task_profiles,
});
- run(service, &config, &payload_config_str, daemonize, console_path, log_path)
+ run(service, &config, &payload_config_str, console_path, log_path)
}
const EMPTY_PAYLOAD_APK: &str = "com.android.microdroid.empty_payload";
@@ -180,7 +179,6 @@
work_dir: Option<PathBuf>,
storage: Option<&Path>,
storage_size: Option<u64>,
- daemonize: bool,
console_path: Option<&Path>,
log_path: Option<&Path>,
debug_level: DebugLevel,
@@ -211,7 +209,6 @@
storage_size,
/* config_path= */ None,
Some(payload_binary_name.to_owned()),
- daemonize,
console_path,
log_path,
debug_level,
@@ -229,7 +226,6 @@
name: Option<String>,
service: &dyn IVirtualizationService,
config_path: &Path,
- daemonize: bool,
console_path: Option<&Path>,
log_path: Option<&Path>,
mem: Option<u32>,
@@ -255,7 +251,6 @@
service,
&VirtualMachineConfig::RawConfig(config),
&format!("{:?}", config_path),
- daemonize,
console_path,
log_path,
)
@@ -277,7 +272,6 @@
service: &dyn IVirtualizationService,
config: &VirtualMachineConfig,
payload_config: &str,
- daemonize: bool,
console_path: Option<&Path>,
log_path: Option<&Path>,
) -> Result<(), Error> {
@@ -286,8 +280,6 @@
File::create(console_path)
.with_context(|| format!("Failed to open console file {:?}", console_path))?,
)
- } else if daemonize {
- None
} else {
Some(duplicate_stdout()?)
};
@@ -296,8 +288,6 @@
File::create(log_path)
.with_context(|| format!("Failed to open log file {:?}", log_path))?,
)
- } else if daemonize {
- None
} else {
Some(duplicate_stdout()?)
};
@@ -314,17 +304,10 @@
state_to_str(vm.state()?)
);
- if daemonize {
- // Pass the VM reference back to VirtualizationService and have it hold it in the
- // background.
- service.debugHoldVmRef(&vm.vm).context("Failed to pass VM to VirtualizationService")?;
- } 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.
- let death_reason = vm.wait_for_death();
- println!("VM ended: {:?}", death_reason);
- }
-
+ // 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.
+ let death_reason = vm.wait_for_death();
+ println!("VM ended: {:?}", death_reason);
Ok(())
}