mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-10 20:19:07 +00:00
devices: proxy: print failed command on error
Add some context for debugging failures so it is possible to determine which register read is failing. BUG=None TEST=./build_test.py Change-Id: I6084971bc6dbd1f7b5d46e6c5d7ba017bb32edc6 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1893637 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
ecfed3ab95
commit
1de9cb53e1
1 changed files with 12 additions and 12 deletions
|
@ -37,7 +37,7 @@ impl Display for Error {
|
||||||
|
|
||||||
const SOCKET_TIMEOUT_MS: u64 = 2000;
|
const SOCKET_TIMEOUT_MS: u64 = 2000;
|
||||||
|
|
||||||
#[derive(MsgOnSocket)]
|
#[derive(Debug, MsgOnSocket)]
|
||||||
enum Command {
|
enum Command {
|
||||||
Read {
|
Read {
|
||||||
len: u32,
|
len: u32,
|
||||||
|
@ -216,12 +216,12 @@ impl ProxyDevice {
|
||||||
|
|
||||||
/// Runs the callback given in `new_with_custom_command` in the child device process.
|
/// Runs the callback given in `new_with_custom_command` in the child device process.
|
||||||
pub fn run_user_command(&self) {
|
pub fn run_user_command(&self) {
|
||||||
self.sync_send(Command::RunUserCommand);
|
self.sync_send(&Command::RunUserCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a command that does not expect a response from the child device process.
|
/// Send a command that does not expect a response from the child device process.
|
||||||
fn send_no_result(&self, cmd: Command) {
|
fn send_no_result(&self, cmd: &Command) {
|
||||||
let res = self.sock.send(&cmd);
|
let res = self.sock.send(cmd);
|
||||||
if let Err(e) = res {
|
if let Err(e) = res {
|
||||||
error!(
|
error!(
|
||||||
"failed write to child device process {}: {}",
|
"failed write to child device process {}: {}",
|
||||||
|
@ -231,13 +231,13 @@ impl ProxyDevice {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a command and read its response from the child device process.
|
/// Send a command and read its response from the child device process.
|
||||||
fn sync_send(&self, cmd: Command) -> Option<CommandResult> {
|
fn sync_send(&self, cmd: &Command) -> Option<CommandResult> {
|
||||||
self.send_no_result(cmd);
|
self.send_no_result(cmd);
|
||||||
match self.sock.recv() {
|
match self.sock.recv() {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!(
|
error!(
|
||||||
"failed read from child device process {}: {}",
|
"failed to read result of {:?} from child device process {}: {}",
|
||||||
self.debug_label, e,
|
cmd, self.debug_label, e,
|
||||||
);
|
);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ impl BusDevice for ProxyDevice {
|
||||||
buffer[0..data.len()].clone_from_slice(data);
|
buffer[0..data.len()].clone_from_slice(data);
|
||||||
let reg_idx = reg_idx as u32;
|
let reg_idx = reg_idx as u32;
|
||||||
let offset = offset as u32;
|
let offset = offset as u32;
|
||||||
self.send_no_result(Command::WriteConfig {
|
self.send_no_result(&Command::WriteConfig {
|
||||||
reg_idx,
|
reg_idx,
|
||||||
offset,
|
offset,
|
||||||
len,
|
len,
|
||||||
|
@ -266,7 +266,7 @@ impl BusDevice for ProxyDevice {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn config_register_read(&self, reg_idx: usize) -> u32 {
|
fn config_register_read(&self, reg_idx: usize) -> u32 {
|
||||||
let res = self.sync_send(Command::ReadConfig(reg_idx as u32));
|
let res = self.sync_send(&Command::ReadConfig(reg_idx as u32));
|
||||||
if let Some(CommandResult::ReadConfigResult(val)) = res {
|
if let Some(CommandResult::ReadConfigResult(val)) = res {
|
||||||
val
|
val
|
||||||
} else {
|
} else {
|
||||||
|
@ -277,7 +277,7 @@ impl BusDevice for ProxyDevice {
|
||||||
fn read(&mut self, offset: u64, data: &mut [u8]) {
|
fn read(&mut self, offset: u64, data: &mut [u8]) {
|
||||||
let len = data.len() as u32;
|
let len = data.len() as u32;
|
||||||
if let Some(CommandResult::ReadResult(buffer)) =
|
if let Some(CommandResult::ReadResult(buffer)) =
|
||||||
self.sync_send(Command::Read { len, offset })
|
self.sync_send(&Command::Read { len, offset })
|
||||||
{
|
{
|
||||||
let len = data.len();
|
let len = data.len();
|
||||||
data.clone_from_slice(&buffer[0..len]);
|
data.clone_from_slice(&buffer[0..len]);
|
||||||
|
@ -288,7 +288,7 @@ impl BusDevice for ProxyDevice {
|
||||||
let mut buffer = [0u8; 8];
|
let mut buffer = [0u8; 8];
|
||||||
let len = data.len() as u32;
|
let len = data.len() as u32;
|
||||||
buffer[0..data.len()].clone_from_slice(data);
|
buffer[0..data.len()].clone_from_slice(data);
|
||||||
self.send_no_result(Command::Write {
|
self.send_no_result(&Command::Write {
|
||||||
len,
|
len,
|
||||||
offset,
|
offset,
|
||||||
data: buffer,
|
data: buffer,
|
||||||
|
@ -298,6 +298,6 @@ impl BusDevice for ProxyDevice {
|
||||||
|
|
||||||
impl Drop for ProxyDevice {
|
impl Drop for ProxyDevice {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.sync_send(Command::Shutdown);
|
self.sync_send(&Command::Shutdown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue