public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvmtool: aarch64: fix path to uncompressed kernel images.
@ 2016-07-26 14:09 Jorge Ramirez-Ortiz
  2016-07-27 14:41 ` Jorge Ramirez
  2016-07-29 11:08 ` Will Deacon
  0 siblings, 2 replies; 5+ messages in thread
From: Jorge Ramirez-Ortiz @ 2016-07-26 14:09 UTC (permalink / raw)
  To: jorge.ramirez-ortiz, will.deacon, sasha.levin; +Cc: penberg, kvm

Some architectures require that the bootloader uncompresses the image
before executing the kernel; since lkvm will not uncompress the kernel
image, the default image names need to be modified to address this
matter.

Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Tested-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
---
 builtin-run.c | 55 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 44 insertions(+), 11 deletions(-)

diff --git a/builtin-run.c b/builtin-run.c
index 72b878d..6290979 100644
--- a/builtin-run.c
+++ b/builtin-run.c
@@ -194,19 +194,26 @@ panic_kvm:
 
 static char kernel[PATH_MAX];
 
-static const char *host_kernels[] = {
+static const char *host_gz_kernels[] = {
 	"/boot/vmlinuz",
 	"/boot/bzImage",
 	NULL
 };
 
-static const char *default_kernels[] = {
+static const char *default_gz_kernels[] = {
 	"./bzImage",
 	"arch/" BUILD_ARCH "/boot/bzImage",
 	"../../arch/" BUILD_ARCH "/boot/bzImage",
 	NULL
 };
 
+static const char *default_kernels[] = {
+	"./Image",
+	"arch/" BUILD_ARCH "/boot/Image",
+	"../../arch/" BUILD_ARCH "/boot/Image",
+	NULL
+};
+
 static const char *default_vmlinux[] = {
 	"vmlinux",
 	"../../../vmlinux",
@@ -214,28 +221,44 @@ static const char *default_vmlinux[] = {
 	NULL
 };
 
+static const char *uncompressed_boot[] = {
+	"aarch64",
+	NULL
+};
+
 static void kernel_usage_with_options(void)
 {
-	const char **k;
+	const char **k, **j;
 	struct utsname uts;
 
+	if (uname(&uts) < 0)
+		return;
+
+	j = &uncompressed_boot[0];
+	while (*j) {
+		if (strncmp(uts.machine, *j, sizeof(uts.machine)) == 0)
+			break;
+		j++;
+	}
+
 	fprintf(stderr, "Fatal: could not find default kernel image in:\n");
-	k = &default_kernels[0];
+	k = *j ? &default_kernels[0] : &default_gz_kernels[0];
 	while (*k) {
 		fprintf(stderr, "\t%s\n", *k);
 		k++;
 	}
 
-	if (uname(&uts) < 0)
-		return;
+	if (*j)
+		goto done;
 
-	k = &host_kernels[0];
+	k = &host_gz_kernels[0];
 	while (*k) {
 		if (snprintf(kernel, PATH_MAX, "%s-%s", *k, uts.release) < 0)
 			return;
 		fprintf(stderr, "\t%s\n", kernel);
 		k++;
 	}
+done:
 	fprintf(stderr, "\nPlease see '%s run --help' for more options.\n\n",
 		KVM_BINARY_NAME);
 }
@@ -285,11 +308,21 @@ static u64 get_ram_size(int nr_cpus)
 
 static const char *find_kernel(void)
 {
-	const char **k;
+	const char **k, **j;
 	struct stat st;
 	struct utsname uts;
 
-	k = &default_kernels[0];
+	if (uname(&uts) < 0)
+		return NULL;
+
+	j = &uncompressed_boot[0];
+	while (*j) {
+		if (strncmp(uts.machine, *j, sizeof(uts.machine)) == 0)
+			break;
+		j++;
+	}
+
+	k = *j ? &default_kernels[0] : &default_gz_kernels[0];
 	while (*k) {
 		if (stat(*k, &st) < 0 || !S_ISREG(st.st_mode)) {
 			k++;
@@ -299,10 +332,10 @@ static const char *find_kernel(void)
 		return kernel;
 	}
 
-	if (uname(&uts) < 0)
+	if (*j)
 		return NULL;
 
-	k = &host_kernels[0];
+	k = &host_gz_kernels[0];
 	while (*k) {
 		if (snprintf(kernel, PATH_MAX, "%s-%s", *k, uts.release) < 0)
 			return NULL;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-08-09 15:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-26 14:09 [PATCH] kvmtool: aarch64: fix path to uncompressed kernel images Jorge Ramirez-Ortiz
2016-07-27 14:41 ` Jorge Ramirez
2016-07-29 11:08 ` Will Deacon
2016-08-02  9:23   ` Jorge Ramirez
2016-08-09 15:10     ` Jorge Ramirez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox