Support console input to VM
createVm accepts a new ParcelFileDescriptor which when set is used as
the console input in the VM. The `vm` tool sets this to stdin unless
explicitly specified via `--console-in`. This will be useful for
bringing up custom OSes.
Note that Java APIs for this is not added in this CL.
Bug: 263360203
Test: Start a vm using the `vm` tool. Type something. Then do `cat
/dev/console` in the VM. It shows the typed characters.
Change-Id: I5d0dfcc4852387ec50897a8dcae2935dd4a2dd9a
diff --git a/vm/src/main.rs b/vm/src/main.rs
index bc3f4da..0800f57 100644
--- a/vm/src/main.rs
+++ b/vm/src/main.rs
@@ -74,6 +74,10 @@
#[clap(long)]
console: Option<PathBuf>,
+ /// Path to file for VM console input.
+ #[clap(long)]
+ console_in: Option<PathBuf>,
+
/// Path to file for VM log output.
#[clap(long)]
log: Option<PathBuf>,
@@ -138,6 +142,10 @@
#[clap(long)]
console: Option<PathBuf>,
+ /// Path to file for VM console input.
+ #[clap(long)]
+ console_in: Option<PathBuf>,
+
/// Path to file for VM log output.
#[clap(long)]
log: Option<PathBuf>,
@@ -193,6 +201,10 @@
#[clap(long)]
console: Option<PathBuf>,
+ /// Path to file for VM console input.
+ #[clap(long)]
+ console_in: Option<PathBuf>,
+
/// Path to file for VM log output.
#[clap(long)]
log: Option<PathBuf>,
@@ -277,6 +289,7 @@
config_path,
payload_binary_name,
console,
+ console_in,
log,
debug,
protected,
@@ -297,6 +310,7 @@
config_path,
payload_binary_name,
console.as_deref(),
+ console_in.as_deref(),
log.as_deref(),
debug,
protected,
@@ -313,6 +327,7 @@
storage,
storage_size,
console,
+ console_in,
log,
debug,
protected,
@@ -328,6 +343,7 @@
storage.as_deref(),
storage_size,
console.as_deref(),
+ console_in.as_deref(),
log.as_deref(),
debug,
protected,
@@ -337,12 +353,13 @@
gdb,
kernel.as_deref(),
),
- Opt::Run { name, config, cpu_topology, task_profiles, console, log, gdb } => {
+ Opt::Run { name, config, cpu_topology, task_profiles, console, console_in, log, gdb } => {
command_run(
name,
get_service()?.as_ref(),
&config,
console.as_deref(),
+ console_in.as_deref(),
log.as_deref(),
/* mem */ None,
cpu_topology,