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@xxxxxxxxxx> Tested-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@xxxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html