From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-ppc@nongnu.org, Alexander Graf <agraf@suse.de>
Subject: [Qemu-devel] [PATCH 4/4] spapr: add more details error description of why load_elf() failed
Date: Wed, 22 Jan 2014 16:20:41 +1100 [thread overview]
Message-ID: <1390368041-2184-5-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1390368041-2184-1-git-send-email-aik@ozlabs.ru>
This makes use of new error codes which load_elf() can return.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
hw/ppc/spapr.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 851ce4b..18a4872 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1306,15 +1306,26 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
- if (kernel_size < 0) {
+ if (kernel_size == ELF_LOAD_WRONG_ENDIAN) {
kernel_size = load_elf(kernel_filename,
translate_kernel_address, NULL,
NULL, &lowaddr, NULL, 0, ELF_MACHINE, 0);
kernel_le = kernel_size > 0;
}
if (kernel_size < 0) {
- fprintf(stderr, "qemu: could not load kernel '%s'\n",
- kernel_filename);
+ switch (kernel_size) {
+ case ELF_LOAD_WRONG_ARCH:
+ fprintf(stderr, "qemu: could not load kernel '%s' from incompatible arhitecture\n",
+ kernel_filename);
+ break;
+ case ELF_LOAD_NOT_ELF:
+ fprintf(stderr, "qemu: '%s' is not ELF\n", kernel_filename);
+ break;
+ default:
+ fprintf(stderr, "qemu: could not load kernel '%s'\n",
+ kernel_filename);
+ break;
+ }
exit(1);
}
--
1.8.4.rc4
next prev parent reply other threads:[~2014-01-22 5:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-22 5:20 [Qemu-devel] [PATCH 0/4 v2] elf loader: exit if incompatible architecture is detected Alexey Kardashevskiy
2014-01-22 5:20 ` [Qemu-devel] [PATCH 1/4] spapr: support only ELF kernel images Alexey Kardashevskiy
2014-01-22 5:20 ` [Qemu-devel] [PATCH 2/4] moxie: fix load_elf() usage Alexey Kardashevskiy
2014-01-31 7:18 ` Alexander Graf
2014-01-22 5:20 ` [Qemu-devel] [PATCH 3/4] elf-loader: add more return codes Alexey Kardashevskiy
2014-01-22 7:27 ` Alexey Kardashevskiy
2014-01-31 2:15 ` Alexey Kardashevskiy
2014-01-22 5:20 ` Alexey Kardashevskiy [this message]
2014-01-31 7:20 ` [Qemu-devel] [PATCH 4/4] spapr: add more details error description of why load_elf() failed Alexander Graf
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=1390368041-2184-5-git-send-email-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=agraf@suse.de \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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 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).