diff options
author | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2018-11-12 12:01:05 +1100 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2018-11-16 13:55:29 +1100 |
commit | cf30fdd3100a425f2f01214ca726f0641f844eec (patch) | |
tree | 579c4082794e909d71ea172a1948ed553ed19b17 /discover/ipmi.c | |
parent | 2bc0df4aa35a89c5af7e54f459e2bbde20ca6a7e (diff) | |
download | talos-petitboot-cf30fdd3100a425f2f01214ca726f0641f844eec.tar.gz talos-petitboot-cf30fdd3100a425f2f01214ca726f0641f844eec.zip |
discover: Nicely format IPMI response buffersv1.9.2
A few places where we print out the response buffer from an IPMI command
weren't updated when log timestamps were added, resulting in very hard
to read output. Add a little helper to format buffers and use it to
print these with only one timestamp.
Example:
[04:59:01] ipmi_get_bmc_versions: BMC version resp [0][16]:
0x00 0x20 0x01 0x02 0x13 0x02 0xbf 0x00
0x00 0x00 0xbb 0xaa 0x58 0x98 0x01 0x00
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'discover/ipmi.c')
-rw-r--r-- | discover/ipmi.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/discover/ipmi.c b/discover/ipmi.c index 840fdee..ae02bb0 100644 --- a/discover/ipmi.c +++ b/discover/ipmi.c @@ -326,6 +326,7 @@ void ipmi_get_bmc_mac(struct ipmi *ipmi, uint8_t *buf) uint16_t resp_len = 8; uint8_t resp[8]; uint8_t req[] = { 0x1, 0x5, 0x0, 0x0 }; + char *debug_buf; int i, rc; rc = ipmi_transaction(ipmi, IPMI_NETFN_TRANSPORT, @@ -334,14 +335,15 @@ void ipmi_get_bmc_mac(struct ipmi *ipmi, uint8_t *buf) resp, &resp_len, ipmi_timeout); - pb_debug_fn("BMC MAC resp [%d][%d]:\n", rc, resp_len); + debug_buf = format_buffer(ipmi, resp, resp_len); + pb_debug_fn("BMC MAC resp [%d][%d]:\n%s\n", + rc, resp_len, debug_buf); + talloc_free(debug_buf); if (rc == 0 && resp_len > 0) { for (i = 2; i < resp_len; i++) { - pb_debug(" %x", resp[i]); buf[i - 2] = resp[i]; } - pb_debug("\n"); } } @@ -354,7 +356,8 @@ void ipmi_get_bmc_versions(struct ipmi *ipmi, struct system_info *info) { uint16_t resp_len = 16; uint8_t resp[16], bcd; - int i, rc; + char *debug_buf; + int rc; /* Retrieve info from current side */ rc = ipmi_transaction(ipmi, IPMI_NETFN_APP, @@ -363,13 +366,10 @@ void ipmi_get_bmc_versions(struct ipmi *ipmi, struct system_info *info) resp, &resp_len, ipmi_timeout); - pb_debug_fn("BMC version resp [%d][%d]:\n", rc, resp_len); - if (resp_len > 0) { - for (i = 0; i < resp_len; i++) { - pb_debug(" %x", resp[i]); - } - pb_debug("\n"); - } + debug_buf = format_buffer(ipmi, resp, resp_len); + pb_debug_fn("BMC version resp [%d][%d]:\n%s\n", + rc, resp_len, debug_buf); + talloc_free(debug_buf); if (rc == 0 && (resp_len == 12 || resp_len == 16)) { info->bmc_current = talloc_array(info, char *, 4); @@ -407,13 +407,10 @@ void ipmi_get_bmc_versions(struct ipmi *ipmi, struct system_info *info) resp, &resp_len, ipmi_timeout); - pb_debug_fn("BMC golden resp [%d][%d]:\n", rc, resp_len); - if (resp_len > 0) { - for (i = 0; i < resp_len; i++) { - pb_debug(" %x", resp[i]); - } - pb_debug("\n"); - } + debug_buf = format_buffer(ipmi, resp, resp_len); + pb_debug_fn("BMC golden resp [%d][%d]:\n%s\n", + rc, resp_len, debug_buf); + talloc_free(debug_buf); if (rc == 0 && (resp_len == 12 || resp_len == 16)) { info->bmc_golden = talloc_array(info, char *, 4); |