devices: vhost-user: console: always restore terminal capabilities

We used to bail early if an error happened while we run the console
device, leaving the terminal in raw mode.

BUG=None
TEST=cargo build

Change-Id: I3dc4a681f736246548d1cc7b7eab0bfd429587be
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439667
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
This commit is contained in:
Alexandre Courbot 2022-02-04 17:31:31 +09:00 committed by Commit Bot
parent ffa04d7a5e
commit 5d12163091

View file

@ -326,14 +326,16 @@ pub fn run_console_device(program_name: &str, args: &[&str]) -> anyhow::Result<(
stdin: true,
};
if let Err(e) = run_console(&params, &socket) {
bail!("error occurred: {:#}", e);
}
let res = run_console(&params, &socket);
// Restore terminal capabilities back to what they were before
stdin()
.set_canon_mode()
.context("Failed to restore canonical mode for terminal")?;
if let Err(e) = res {
bail!("error occurred: {:#}", e);
}
Ok(())
}