From: Peter Maydell <peter.maydell@linaro.org>
To: Vishal Chourasia <vishalc@linux.ibm.com>
Cc: npiggin@gmail.com, adityag@linux.ibm.com, milesg@linux.ibm.com,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] hw/ppc/pnv: Improve kernel/initrd load failure error messages
Date: Mon, 13 Oct 2025 09:35:12 +0100 [thread overview]
Message-ID: <CAFEAcA8zGH1sHL45WU=E2p4p0EizuOs3QRaniHW7ES-CQDPajg@mail.gmail.com> (raw)
In-Reply-To: <aOyj5p2xzoxCyYZC@linux.ibm.com>
On Mon, 13 Oct 2025 at 08:02, Vishal Chourasia <vishalc@linux.ibm.com> wrote:
>
> On Tue, Oct 07, 2025 at 02:29:52PM +0100, Peter Maydell wrote:
> > On Tue, 7 Oct 2025 at 13:59, Vishal Chourasia <vishalc@linux.ibm.com> wrote:
> > >
> > > When QEMU fails to load the kernel or initrd image, it previously emitted
> > > a generic error message such as:
> > >
> > > qemu-system-ppc64: Could not load kernel 'vmlinux'
> > >
> > > This provides little context on why the failure occurred, which can make
> > > debugging difficult, especially for new users or when dealing with large
> > > images.
> > >
> > > The new messages also include the configured size limits (in MiB) to help
> > > users verify that their image files are within acceptable bounds.
> >
> > > if (kernel_size < 0) {
> > > error_report("Could not load kernel '%s'",
> > > machine->kernel_filename);
> > > + error_report(
> > > + "Possible reasons: file not found, permission denied, or size "
> > > + "exceeds the maximum supported limit (%ld MiB).",
> > > + KERNEL_MAX_SIZE / 1024 / 1024);
> > > exit(1);
> > > }
> >
> > Rather than printing a list of reasons why the load might
> > have failed, I think it would be better if we enhanced
> > the error handling in load_image_targphys() and friends
> > (i.e. use Error), so that these functions can report back
> > to the caller exactly why they failed and then the caller
> > can give that error message to the user. That way we can
> > improve the error reporting for every board that uses
> > these load functions.
> Hello Peter,
>
> Wouldn't it be better to print the error inside the function itself.
No, because some users of this family of load functions
use a sequence of calls to handle different possible
formats. We don't want the function to load file format A
to print any errors if we're then going to continue and
successfully load the file as format B.
More generally, our usual coding practice for functions
is that they use Error to tell the caller what went wrong,
and it's the caller that then gets to decide whether they
want to print an error and exit, tell the monitor about
an error, or just continue to try something else instead.
-- PMM
next prev parent reply other threads:[~2025-10-13 8:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 9:12 [PATCH] hw/ppc/pnv: Improve kernel/initrd load failure error messages Vishal Chourasia
2025-10-07 13:29 ` Peter Maydell
2025-10-13 7:01 ` Vishal Chourasia
2025-10-13 8:35 ` Peter Maydell [this message]
2025-10-13 10:18 ` Aditya Gupta
2025-10-13 10:37 ` Peter Maydell
2025-10-13 10:54 ` Harsh Prateek Bora
2025-10-13 9:50 ` Vishal Chourasia
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='CAFEAcA8zGH1sHL45WU=E2p4p0EizuOs3QRaniHW7ES-CQDPajg@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=adityag@linux.ibm.com \
--cc=milesg@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=vishalc@linux.ibm.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).