All of lore.kernel.org
 help / color / mirror / Atom feed
From: duchangbin via <qemu-devel@nongnu.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: duchangbin <changbin.du@huawei.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	"qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [PATCH v2] hw/arm/boot: Report error msg if loading elf/dtb failed
Date: Tue, 3 Sep 2024 13:39:26 +0000	[thread overview]
Message-ID: <263aa8df87ff461d96fdc55763aeac79@huawei.com> (raw)
In-Reply-To: <7c67704e-a067-4b6e-8acb-51b33cf17ee0@linaro.org>

On Mon, Sep 02, 2024 at 09:55:19PM +0200, Philippe Mathieu-Daudé wrote:
> Hi Changbin,
> 
> On 30/8/24 12:53, Changbin Du via wrote:
> > Print errors before exit. Do not exit silently.
> > 
> > Signed-off-by: Changbin Du <changbin.du@huawei.com>
> > 
> > ---
> > v2: remove msg for arm_load_dtb.
> > ---
> >   hw/arm/boot.c | 1 +
> >   1 file changed, 1 insertion(+)
> > 
> > diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> > index d480a7da02cf..e15bf097a559 100644
> > --- a/hw/arm/boot.c
> > +++ b/hw/arm/boot.c
> > @@ -839,6 +839,7 @@ static ssize_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry,
> >                         1, data_swab, as);
> >       if (ret <= 0) {
> >           /* The header loaded but the image didn't */
> > +        error_report("could not load elf '%s'", info->kernel_filename);
> 
> "Could ..." (caps)
> 
> "hw/loader.h" is not well documented, but it seems load_elf*() returns:
> 
>   #define ELF_LOAD_FAILED       -1
>   #define ELF_LOAD_NOT_ELF      -2
>   #define ELF_LOAD_WRONG_ARCH   -3
>   #define ELF_LOAD_WRONG_ENDIAN -4
>   #define ELF_LOAD_TOO_BIG      -5
> 
> And we can display this error calling:
> 
>   const char *load_elf_strerror(ssize_t error);
> 
> So we can be more precise here using:
> 
>   error_report("Could not load elf '%s'", info->kernel_filename,
>                load_elf_strerror(ret));
> 
> >           exit(1);
> >       }
> 
> Better (but out of scope of this patch) could be to pass an Error *errp
> argument to the load_elf*() family of functions, and fill it with the
> appropriate error message.
>
Thanks for your suggestion. I changed it as below:
+        error_report("Couldn't load elf '%s': %s",
+                     info->kernel_filename, load_elf_strerror(ret));

$ qemu-system-aarch64 -M virt -kernel /work/linux/vmlinux
qemu-system-aarch64: Couldn't load elf '/work/linux/vmlinux': The image is from incompatible architecture

> Regards,
> 
> Phil.

-- 
Cheers,
Changbin Du

      parent reply	other threads:[~2024-09-03 14:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-30 10:53 [PATCH v2] hw/arm/boot: Report error msg if loading elf/dtb failed Changbin Du via
2024-08-30 10:53 ` Changbin Du via
2024-09-02 19:55 ` Philippe Mathieu-Daudé
2024-09-02 20:00   ` Philippe Mathieu-Daudé
2024-09-03  9:20     ` Peter Maydell
2024-09-03 13:40       ` Philippe Mathieu-Daudé
2024-09-03 13:39   ` duchangbin via [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=263aa8df87ff461d96fdc55763aeac79@huawei.com \
    --to=qemu-devel@nongnu.org \
    --cc=changbin.du@huawei.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.