Patchwork [RFC,5/8] package/kexec-lite: Add a package for the kexec-lite tools

login
register
mail settings
Submitter Jeremy Kerr
Date Jan. 16, 2014, 8:52 a.m.
Message ID <1389862338.919140.855251422258.5.gpush@pablo>
Download mbox | patch
Permalink /patch/311637/
State Superseded
Headers show

Comments

Jeremy Kerr - Jan. 16, 2014, 8:52 a.m.
Kexec-lite is a tiny impementation of kexec for devicetree-based
platforms.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>

---
 package/Config.in                                 |    1 
 package/kexec-lite/Config.in                      |    9 +++
 package/kexec-lite/kexec-lite-clean-restart.patch |   34 ++++++++++++++
 package/kexec-lite/kexec-lite.mk                  |   20 ++++++++
 4 files changed, 64 insertions(+)
Baruch Siach - Jan. 16, 2014, 9:36 a.m.
Hi Jeremy,

On Thu, Jan 16, 2014 at 04:52:18PM +0800, Jeremy Kerr wrote:
> Kexec-lite is a tiny impementation of kexec for devicetree-based
> platforms.
> 
> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>

[...]

> diff --git a/package/kexec-lite/Config.in b/package/kexec-lite/Config.in
> new file mode 100644
> index 00000000..0dc05155
> --- /dev/null
> +++ b/package/kexec-lite/Config.in
> @@ -0,0 +1,9 @@
> +config BR2_PACKAGE_KEXEC_LITE
> +	bool "kexec-lite"
> +	depends on BR2_powerpc
> +	select BR2_PACKAGE_LIBELF
> +	select BR2_PACKAGE_DTC
> +	select BR2_PACKAGE_DTC_PROGRAMS
> +	help
> +	  Kexec is a user space utiltity for loading another kernel
> +	  and asking the currently running kernel to do something with it.

This looks like a description of the generic kexec. You should mention that 
this is a special version as the commit log says.

[...]

> diff --git a/package/kexec-lite/kexec-lite.mk 
> b/package/kexec-lite/kexec-lite.mk
> new file mode 100644
> index 00000000..4d844f43
> --- /dev/null
> +++ b/package/kexec-lite/kexec-lite.mk
> @@ -0,0 +1,20 @@
> +################################################################################
> +#
> +# kexec
> +#
> +################################################################################
> +
> +KEXEC_LITE_VERSION = 6c762a7

Full commit id.

> +KEXEC_LITE_SITE = git://github.com/antonblanchard/kexec-lite

Please use the github helper. See docs/manual/adding-packages-tips.txt.

> +KEXEC_LITE_LICENSE = GPL
> +KEXEC_LITE_DEPENDENCIES = libelf dtc
> +
> +define KEXEC_LITE_BUILD_CMDS
> +	$(MAKE) CC="$(TARGET_CC)" LD="$(TARGET_LD)" -C $(@D) all
> +endef
> +
> +define KEXEC_LITE_INSTALL_TARGET_CMDS
> +	$(INSTALL) -D -m 755 $(@D)/kexec $(TARGET_DIR)/usr/sbin/
> +endef
> +
> +$(eval $(generic-package))

baruch
Jerzy Grzegorek - Jan. 16, 2014, 1:17 p.m.
Hi Jeremy,

> Kexec-lite is a tiny impementation of kexec for devicetree-based
> platforms.
>
> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
>
> ---
>   package/Config.in                                 |    1
>   package/kexec-lite/Config.in                      |    9 +++
>   package/kexec-lite/kexec-lite-clean-restart.patch |   34 ++++++++++++++

kexec-lite-01-clean-restart.patch


>   package/kexec-lite/kexec-lite.mk                  |   20 ++++++++
>   4 files changed, 64 insertions(+)

[...]

> diff --git a/package/kexec-lite/kexec-lite.mk b/package/kexec-lite/kexec-lite.mk
> new file mode 100644
> index 00000000..4d844f43
> --- /dev/null
> +++ b/package/kexec-lite/kexec-lite.mk
> @@ -0,0 +1,20 @@
> +################################################################################
> +#
> +# kexec

# kexec-lite

Regards,
Jerzy

> +#
> +################################################################################
> +
> +KEXEC_LITE_VERSION = 6c762a7
> +KEXEC_LITE_SITE = git://github.com/antonblanchard/kexec-lite
> +KEXEC_LITE_LICENSE = GPL
> +KEXEC_LITE_DEPENDENCIES = libelf dtc
> +
> +define KEXEC_LITE_BUILD_CMDS
> +	$(MAKE) CC="$(TARGET_CC)" LD="$(TARGET_LD)" -C $(@D) all
> +endef
> +
> +define KEXEC_LITE_INSTALL_TARGET_CMDS
> +	$(INSTALL) -D -m 755 $(@D)/kexec $(TARGET_DIR)/usr/sbin/
> +endef
> +
> +$(eval $(generic-package))
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
>
Jeremy Kerr - Jan. 17, 2014, 1:51 a.m.
Hi Baruch,

Thanks for taking a look at the patches.

>> +++ b/package/kexec-lite/Config.in
>> @@ -0,0 +1,9 @@
>> +config BR2_PACKAGE_KEXEC_LITE
>> +	bool "kexec-lite"
>> +	depends on BR2_powerpc
>> +	select BR2_PACKAGE_LIBELF
>> +	select BR2_PACKAGE_DTC
>> +	select BR2_PACKAGE_DTC_PROGRAMS
>> +	help
>> +	  Kexec is a user space utiltity for loading another kernel
>> +	  and asking the currently running kernel to do something with it.
> 
> This looks like a description of the generic kexec. You should mention that 
> this is a special version as the commit log says.

Yep, shamelessly stolen from kexec.mk. :) I've updated this with a
description similar to the changelog.

>> --- /dev/null
>> +++ b/package/kexec-lite/kexec-lite.mk
>> @@ -0,0 +1,20 @@
>> +################################################################################
>> +#
>> +# kexec
>> +#
>> +################################################################################
>> +
>> +KEXEC_LITE_VERSION = 6c762a7
> 
> Full commit id.

Fixed, along with the other git version strings you've mentioned in this
series.

>> +KEXEC_LITE_SITE = git://github.com/antonblanchard/kexec-lite
> 
> Please use the github helper. See docs/manual/adding-packages-tips.txt.

Ah, that's pretty neat. Updated to use $(call github  ...).

I've updated my series with these changes, but will see if there's any
more feedback before reposting.

Cheers,


Jeremy
Thomas Petazzoni - Jan. 30, 2014, 7:46 p.m.
Dear Jeremy Kerr,

On Thu, 16 Jan 2014 16:52:18 +0800, Jeremy Kerr wrote:

> +	select BR2_PACKAGE_LIBELF
> +	select BR2_PACKAGE_DTC
> +	select BR2_PACKAGE_DTC_PROGRAMS

I have no idea how kexec-lite works, but I'm a bit surprised by the
dependency on dtc. Does it builds the Device Tree source at runtime on
the target?

Thomas
Thomas Petazzoni - Jan. 30, 2014, 7:47 p.m.
Dear Jeremy Kerr,

On Thu, 16 Jan 2014 16:52:18 +0800, Jeremy Kerr wrote:

> +KEXEC_LITE_VERSION = 6c762a7
> +KEXEC_LITE_SITE = git://github.com/antonblanchard/kexec-lite
> +KEXEC_LITE_LICENSE = GPL

This should be GPLv2+

It would be nice if the license text was added to the upstream project.
Maybe something that you can suggest to Anton :-)

Thomas
Jeremy Kerr - Feb. 3, 2014, 5:37 a.m.
Hi Thomas,

>> +	select BR2_PACKAGE_LIBELF
>> +	select BR2_PACKAGE_DTC
>> +	select BR2_PACKAGE_DTC_PROGRAMS
> 
> I have no idea how kexec-lite works, but I'm a bit surprised by the
> dependency on dtc. Does it builds the Device Tree source at runtime on
> the target?

Yes; if no device-tree blob is provided on the command-line, it will
invoke dtc to generate one from the current system (ie, from
/proc/device-tree).

Cheers,


Jeremy
Thomas Petazzoni - Feb. 3, 2014, 7:04 a.m.
Dear Jeremy Kerr,

On Mon, 03 Feb 2014 13:37:29 +0800, Jeremy Kerr wrote:

> >> +	select BR2_PACKAGE_LIBELF
> >> +	select BR2_PACKAGE_DTC
> >> +	select BR2_PACKAGE_DTC_PROGRAMS
> > 
> > I have no idea how kexec-lite works, but I'm a bit surprised by the
> > dependency on dtc. Does it builds the Device Tree source at runtime on
> > the target?
> 
> Yes; if no device-tree blob is provided on the command-line, it will
> invoke dtc to generate one from the current system (ie, from
> /proc/device-tree).

Ok, then in this kind of case, we like to do:

	# run-time dependency only
	select BR2_PACKAGE_DTC
	select BR2_PACKAGE_DTC_PROGRAMS

so that we remember why this dependency is expressed in the Config.in,
but not in the package .mk file.

Thanks!

Thomas
Jeremy Kerr - Feb. 28, 2014, 7:11 a.m.
Hi Thomas,

>>> +	select BR2_PACKAGE_LIBELF
>>> +	select BR2_PACKAGE_DTC
>>> +	select BR2_PACKAGE_DTC_PROGRAMS
>>
>> I have no idea how kexec-lite works, but I'm a bit surprised by the
>> dependency on dtc. Does it builds the Device Tree source at runtime on
>> the target?
> 
> Yes; if no device-tree blob is provided on the command-line, it will
> invoke dtc to generate one from the current system (ie, from
> /proc/device-tree).

OK, I'm slightly incorrect here - kexec-lite requires the dtc libraries
at build-time (we need to manipulate the device tree to update the
reserved memory map), and may also call dtc at runtime too.

So, I'd propose a:

	select BR2_PACKAGE_DTC
	# run-time dependency only
	select BR2_PACKAGE_DTC_PROGRAMS

- is that sensible?

Cheers,


Jeremy
Thomas Petazzoni - Feb. 28, 2014, 7:37 a.m.
Dear Jeremy Kerr,

On Fri, 28 Feb 2014 15:11:24 +0800, Jeremy Kerr wrote:

> OK, I'm slightly incorrect here - kexec-lite requires the dtc libraries
> at build-time (we need to manipulate the device tree to update the
> reserved memory map), and may also call dtc at runtime too.
> 
> So, I'd propose a:
> 
> 	select BR2_PACKAGE_DTC
> 	# run-time dependency only
> 	select BR2_PACKAGE_DTC_PROGRAMS
> 
> - is that sensible?

In theory, yes. In practice, since you need BR2_PACKAGE_DTC at build
time, it means that you will have "dtc" in the <pkg>_DEPENDENCIES
variable of your package, which means that the dtc package (both the
library and programs) will be built before your package. So practically
speaking, BR2_PACKAGE_DTC_PROGRAMS will not really be treated as a
run-time dependency only, because it's not provided by a separate
package than dtc.

Thomas

Patch

diff --git a/package/Config.in b/package/Config.in
index 61f4c9e0..f5161475 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -52,6 +52,7 @@  source "package/fio/Config.in"
 source "package/gdb/Config.in"
 source "package/iozone/Config.in"
 source "package/kexec/Config.in"
+source "package/kexec-lite/Config.in"
 source "package/ktap/Config.in"
 source "package/latencytop/Config.in"
 source "package/lmbench/Config.in"
diff --git a/package/kexec-lite/Config.in b/package/kexec-lite/Config.in
new file mode 100644
index 00000000..0dc05155
--- /dev/null
+++ b/package/kexec-lite/Config.in
@@ -0,0 +1,9 @@ 
+config BR2_PACKAGE_KEXEC_LITE
+	bool "kexec-lite"
+	depends on BR2_powerpc
+	select BR2_PACKAGE_LIBELF
+	select BR2_PACKAGE_DTC
+	select BR2_PACKAGE_DTC_PROGRAMS
+	help
+	  Kexec is a user space utiltity for loading another kernel
+	  and asking the currently running kernel to do something with it.
diff --git a/package/kexec-lite/kexec-lite-clean-restart.patch b/package/kexec-lite/kexec-lite-clean-restart.patch
new file mode 100644
index 00000000..faaa93a0
--- /dev/null
+++ b/package/kexec-lite/kexec-lite-clean-restart.patch
@@ -0,0 +1,34 @@ 
+From 0a654c20e1b9324c57ba4116b52fb6ab33847e1d Mon Sep 17 00:00:00 2001
+From: Jeremy Kerr <jk@ozlabs.org>
+Date: Thu, 8 Aug 2013 17:16:31 +0800
+Subject: [PATCH] kexec: Implement clean restart for busybox init
+
+Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
+---
+ kexec.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/kexec.c b/kexec.c
+index 2edb7df..b2a0c42 100644
+--- a/kexec.c
++++ b/kexec.c
+@@ -27,6 +27,7 @@
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <syscall.h>
++#include <signal.h>
+ #include <libfdt.h>
+ #include <getopt.h>
+ #include <sys/types.h>
+@@ -818,7 +819,7 @@ int main(int argc, char *argv[])
+ 			sync();
+ 			exec_kexec();
+ 		} else {
+-			execlp("shutdown", "shutdown", "-r", "now", NULL);
++			kill(1, SIGQUIT);
+ 		}
+ 
+ 		return -1;
+-- 
+1.7.10.4
+
diff --git a/package/kexec-lite/kexec-lite.mk b/package/kexec-lite/kexec-lite.mk
new file mode 100644
index 00000000..4d844f43
--- /dev/null
+++ b/package/kexec-lite/kexec-lite.mk
@@ -0,0 +1,20 @@ 
+################################################################################
+#
+# kexec
+#
+################################################################################
+
+KEXEC_LITE_VERSION = 6c762a7
+KEXEC_LITE_SITE = git://github.com/antonblanchard/kexec-lite
+KEXEC_LITE_LICENSE = GPL
+KEXEC_LITE_DEPENDENCIES = libelf dtc
+
+define KEXEC_LITE_BUILD_CMDS
+	$(MAKE) CC="$(TARGET_CC)" LD="$(TARGET_LD)" -C $(@D) all
+endef
+
+define KEXEC_LITE_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 755 $(@D)/kexec $(TARGET_DIR)/usr/sbin/
+endef
+
+$(eval $(generic-package))