tpm: report backend request error

Use an Error** for request to let the caller handle error reporting.

This will also allow to inform the frontend of a backend error.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This commit is contained in:
Marc-André Lureau 2018-01-29 19:33:06 +01:00 committed by Stefan Berger
parent c4fb8561bc
commit 6a8a23549a
6 changed files with 33 additions and 36 deletions

View file

@ -183,28 +183,19 @@ static int tpm_emulator_set_locality(TPMEmulator *tpm_emu, uint8_t locty_number,
return 0;
}
static void tpm_emulator_handle_request(TPMBackend *tb, TPMBackendCmd *cmd)
static void tpm_emulator_handle_request(TPMBackend *tb, TPMBackendCmd *cmd,
Error **errp)
{
TPMEmulator *tpm_emu = TPM_EMULATOR(tb);
Error *err = NULL;
DPRINTF("processing TPM command");
if (tpm_emulator_set_locality(tpm_emu, cmd->locty, &err) < 0) {
goto error;
}
if (tpm_emulator_unix_tx_bufs(tpm_emu, cmd->in, cmd->in_len,
if (tpm_emulator_set_locality(tpm_emu, cmd->locty, errp) < 0 ||
tpm_emulator_unix_tx_bufs(tpm_emu, cmd->in, cmd->in_len,
cmd->out, cmd->out_len,
&cmd->selftest_done, &err) < 0) {
goto error;
&cmd->selftest_done, errp) < 0) {
tpm_util_write_fatal_error_response(cmd->out, cmd->out_len);
}
return;
error:
tpm_util_write_fatal_error_response(cmd->out, cmd->out_len);
error_report_err(err);
}
static int tpm_emulator_probe_caps(TPMEmulator *tpm_emu)