Message ID | 1469542146-23979-1-git-send-email-jorge.ramirez-ortiz@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 07/26/2016 04:09 PM, Jorge Ramirez-Ortiz wrote: > 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. or we could do as qemu does - maybe a better option- link lz and attempt to unzip the kernel for aarch64: /* Is it a gzip-compressed file? */ if (len < 2 || compressed_data[0] != 0x1f || compressed_data[1] != 0x8b) { } ... please let me know. > > 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; -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Jorge, On Tue, Jul 26, 2016 at 04:09:06PM +0200, Jorge Ramirez-Ortiz wrote: > 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(-) I just pushed a variant of Andre's previous solution to this problem, which lets you run Image.gz doing something like: $ lkvm run ... -k (zcat Image.gz) Will -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 07/29/2016 01:08 PM, Will Deacon wrote: > Hi Jorge, > > On Tue, Jul 26, 2016 at 04:09:06PM +0200, Jorge Ramirez-Ortiz wrote: >> 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(-) > I just pushed a variant of Andre's previous solution to this problem, > which lets you run Image.gz doing something like: > > $ lkvm run ... -k (zcat Image.gz) but I am not sure this addresses the issue that aarch64 users face when they try run on aarch64 without arguments (ie $ lkvm run). -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08/02/2016 11:23 AM, Jorge Ramirez wrote: > On 07/29/2016 01:08 PM, Will Deacon wrote: >> Hi Jorge, >> >> On Tue, Jul 26, 2016 at 04:09:06PM +0200, Jorge Ramirez-Ortiz wrote: >>> 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(-) >> I just pushed a variant of Andre's previous solution to this problem, >> which lets you run Image.gz doing something like: >> >> $ lkvm run ... -k (zcat Image.gz) > > but I am not sure this addresses the issue that aarch64 users face > when they try run on aarch64 without arguments (ie $ lkvm run). > > > just following up -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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;