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

* Re: [PATCH] kvmtool: aarch64: fix path to uncompressed kernel images.
  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
  1 sibling, 0 replies; 5+ messages in thread
From: Jorge Ramirez @ 2016-07-27 14:41 UTC (permalink / raw)
  To: will.deacon, sasha.levin; +Cc: penberg, kvm

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;



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

* Re: [PATCH] kvmtool: aarch64: fix path to uncompressed kernel images.
  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
  1 sibling, 1 reply; 5+ messages in thread
From: Will Deacon @ 2016-07-29 11:08 UTC (permalink / raw)
  To: Jorge Ramirez-Ortiz; +Cc: sasha.levin, penberg, kvm

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

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

* Re: [PATCH] kvmtool: aarch64: fix path to uncompressed kernel images.
  2016-07-29 11:08 ` Will Deacon
@ 2016-08-02  9:23   ` Jorge Ramirez
  2016-08-09 15:10     ` Jorge Ramirez
  0 siblings, 1 reply; 5+ messages in thread
From: Jorge Ramirez @ 2016-08-02  9:23 UTC (permalink / raw)
  To: Will Deacon; +Cc: sasha.levin, penberg, kvm

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).




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

* Re: [PATCH] kvmtool: aarch64: fix path to uncompressed kernel images.
  2016-08-02  9:23   ` Jorge Ramirez
@ 2016-08-09 15:10     ` Jorge Ramirez
  0 siblings, 0 replies; 5+ messages in thread
From: Jorge Ramirez @ 2016-08-09 15:10 UTC (permalink / raw)
  To: Will Deacon; +Cc: sasha.levin, penberg, kvm

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


^ permalink raw reply	[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