libelf: improve errors in elf_xen_note_check()
PATCH 1/1 libelf: improve errors in elf_xen_note_check()
I recently debugged an isolated failure to boot, with no information other than the logs.
The "Will only load images built for the generic loader or Linux images" string was missing a newline, leading to the subsequent error being appended to this line, rather than having its own line with correctly identified function.
Furthermore, error messages which state "param containing $FOO is not $BAR" is fairly useless for debugging without identifying which bad $FOO caused the failure.
---
I have CC'd both Xen and Tools maintainers as I am not sure who is most appropriate to review/ack. Strictly speaking, the code lives in the Xen subtree, but is arguably more toolstack code than Xen code.
--- xen/common/libelf/libelf-dominfo.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
xen/common/libelf/libelf-dominfo.c +5 -2
@@ -374,7 +374,9 @@ static elf_errorstatus elf_xen_note_check(struct elf_binary *elf, strncmp(parms->guest_os, "linux", 5)) ) {elf_err (elf,"%s: ERROR: Will only load images built for the generic " -"loader or Linux images" , __FUNCTION__); +"loader or Linux images (Not '%.*s' and '%.*s')\n" , + __FUNCTION__, (int )sizeof (parms->loader), parms->loader, + (int )sizeof (parms->guest_os), parms->guest_os);return -1 ; }
@@ -382,7 +384,8 @@ static elf_errorstatus elf_xen_note_check(struct elf_binary *elf, strncmp(parms->xen_ver, "xen-3.0", 7) ) {elf_err (elf,"%s: ERROR: Xen will only load images built " -"for Xen v3.0\n" , __FUNCTION__); +"for Xen v3.0 (Not '%.*s')\n" , __FUNCTION__, + (int )sizeof (parms->xen_ver), parms->xen_ver);return -1 ; }return 0 ;
Signature · 1 line
1.7.10.4
Andrew Cooper writes ("[PATCH] libelf: improve errors in elf_xen_note_check()"):
Quoted 2 lines
I recently debugged an isolated failure to boot, with no information other than the logs.
Thanks for this patch.
Quoted 3 lines
I have CC'd both Xen and Tools maintainers as I am not sure who is most appropriate to review/ack. Strictly speaking, the code lives in the Xen subtree, but is arguably more toolstack code than Xen code.
I was the last person to mess substantially with libelf so I decided that I was the right person to review this.
I trust no-one objects. If they do I may send a patch to MAINTAINERS :-).
Thanks,
Ian.