Remove support for --daemonize
The 'daemonize' feature allowed a VM spawned by shell to be held by
VirtualizationService indefinitely, eg. if adb was disconnected.
The setup is not compatible with the new virtmgr/virtualizationservice
split and can be replaced with 'adb shell vm run ... &' anyway. All
tests and scripts have been migrated away from it, so we can remove it
now.
Bug: 265248057
Bug: 245727626
Test: atest -p packages/modules/Virtualization:avf-presubmit
Change-Id: Iba4fc40ffd9ddc59afaa535cf746872b1d4ba87a
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(())
}