aboutsummaryrefslogtreecommitdiff
path: root/hw/tpm/tpm_passthrough.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2018-01-29 19:33:06 +0100
committerStefan Berger <stefanb@linux.vnet.ibm.com>2018-01-29 14:22:43 -0500
commit6a8a23549a6ddb4af47b032db76badf131c5c2e6 (patch)
tree77ff1a758180aa07eb4239d7db6cf704278aa03f /hw/tpm/tpm_passthrough.c
parentc4fb8561bcec5f3ae3ae2d8a688d1e1aeb247a91 (diff)
downloadqemu-6a8a23549a6ddb4af47b032db76badf131c5c2e6.zip
qemu-6a8a23549a6ddb4af47b032db76badf131c5c2e6.tar.gz
qemu-6a8a23549a6ddb4af47b032db76badf131c5c2e6.tar.bz2
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>
Diffstat (limited to 'hw/tpm/tpm_passthrough.c')
-rw-r--r--hw/tpm/tpm_passthrough.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index fc42fe0..a495fe0 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -80,10 +80,11 @@ static int tpm_passthrough_unix_read(int fd, uint8_t *buf, uint32_t len)
}
return ret;
}
-static int tpm_passthrough_unix_tx_bufs(TPMPassthruState *tpm_pt,
- const uint8_t *in, uint32_t in_len,
- uint8_t *out, uint32_t out_len,
- bool *selftest_done)
+
+static void tpm_passthrough_unix_tx_bufs(TPMPassthruState *tpm_pt,
+ const uint8_t *in, uint32_t in_len,
+ uint8_t *out, uint32_t out_len,
+ bool *selftest_done, Error **errp)
{
ssize_t ret;
bool is_selftest;
@@ -98,9 +99,8 @@ static int tpm_passthrough_unix_tx_bufs(TPMPassthruState *tpm_pt,
ret = qemu_write_full(tpm_pt->tpm_fd, in, in_len);
if (ret != in_len) {
if (!tpm_pt->tpm_op_canceled || errno != ECANCELED) {
- error_report("tpm_passthrough: error while transmitting data "
- "to TPM: %s (%i)",
- strerror(errno), errno);
+ error_setg_errno(errp, errno, "tpm_passthrough: error while "
+ "transmitting data to TPM");
}
goto err_exit;
}
@@ -110,15 +110,14 @@ static int tpm_passthrough_unix_tx_bufs(TPMPassthruState *tpm_pt,
ret = tpm_passthrough_unix_read(tpm_pt->tpm_fd, out, out_len);
if (ret < 0) {
if (!tpm_pt->tpm_op_canceled || errno != ECANCELED) {
- error_report("tpm_passthrough: error while reading data from "
- "TPM: %s (%i)",
- strerror(errno), errno);
+ error_setg_errno(errp, errno, "tpm_passthrough: error while "
+ "reading data from TPM");
}
} else if (ret < sizeof(struct tpm_resp_hdr) ||
tpm_cmd_get_size(out) != ret) {
ret = -1;
- error_report("tpm_passthrough: received invalid response "
- "packet from TPM");
+ error_setg_errno(errp, errno, "tpm_passthrough: received invalid "
+ "response packet from TPM");
}
if (is_selftest && (ret >= sizeof(struct tpm_resp_hdr))) {
@@ -131,18 +130,18 @@ err_exit:
}
tpm_pt->tpm_executing = false;
-
- return ret;
}
-static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd *cmd)
+static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd *cmd,
+ Error **errp)
{
TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
DPRINTF("tpm_passthrough: processing command %p\n", cmd);
tpm_passthrough_unix_tx_bufs(tpm_pt, cmd->in, cmd->in_len,
- cmd->out, cmd->out_len, &cmd->selftest_done);
+ cmd->out, cmd->out_len, &cmd->selftest_done,
+ errp);
}
static void tpm_passthrough_reset(TPMBackend *tb)