vtpmmgr: Print error code to aid debugging
authorJason Andryuk <jandryuk@gmail.com>
Thu, 6 May 2021 13:59:12 +0000 (09:59 -0400)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 7 May 2021 18:50:50 +0000 (19:50 +0100)
tpm_get_error_name returns "Unknown Error Code" when an error string
is not defined.  In that case, we should print the Error Code so it can
be looked up offline.  tpm_get_error_name returns a const string, so
just have the two callers always print the error code so it is always
available.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com>
stubdom/vtpmmgr/tpm.c
stubdom/vtpmmgr/tpm2.c

index 779cddd64ea88764ea6f0624444fda99439967af..83b2bc16b291cd44d96171d5cadc17762564c963 100644 (file)
                        UINT32 rsp_status; \
                        UNPACK_OUT(TPM_RSP_HEADER, &rsp_tag, &rsp_len, &rsp_status); \
                        if (rsp_status != TPM_SUCCESS) { \
-                               vtpmlogerror(VTPM_LOG_TPM, "Failed with return code %s\n", tpm_get_error_name(rsp_status)); \
+                               vtpmlogerror(VTPM_LOG_TPM, "Failed with return code %s (%x)\n", tpm_get_error_name(rsp_status), rsp_status); \
                                status = rsp_status; \
                                goto abort_egress; \
                        } \
index c9f1016ab53f5ffbbe9668d45abb2c06c33c3f07..655e6d164c4654995ebb8532c545078d08521902 100644 (file)
     ptr = unpack_TPM_RSP_HEADER(ptr, \
           &(tag), &(paramSize), &(status));\
     if ((status) != TPM_SUCCESS){ \
-        vtpmlogerror(VTPM_LOG_TPM, "Failed with return code %s\n", tpm_get_error_name(status));\
+        vtpmlogerror(VTPM_LOG_TPM, "Failed with return code %s (%x)\n", tpm_get_error_name(status), (status));\
         goto abort_egress;\
     }\
 } while(0)