[PATCH RFC 4/6] arm64: support reuse-cmdline option

Pratyush Anand panand at redhat.com
Thu Apr 16 09:47:27 PDT 2015


--reuse-cmdline uses cmdline argument of primary kernel. Support this
feature for ARM64.

Signed-off-by: Pratyush Anand <panand at redhat.com>
---
 kexec/arch/arm64/include/arch/options.h | 7 +++++--
 kexec/arch/arm64/kexec-arm64.c          | 8 +++++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/kexec/arch/arm64/include/arch/options.h b/kexec/arch/arm64/include/arch/options.h
index 0d5987b18a25..afe3e9827ff3 100644
--- a/kexec/arch/arm64/include/arch/options.h
+++ b/kexec/arch/arm64/include/arch/options.h
@@ -6,7 +6,8 @@
 #define OPT_INITRD	((OPT_MAX)+2)
 #define OPT_LITE	((OPT_MAX)+3)
 #define OPT_PORT	((OPT_MAX)+4)
-#define OPT_ARCH_MAX	((OPT_MAX)+5)
+#define OPT_REUSE_CMDLINE	((OPT_MAX+5))
+#define OPT_ARCH_MAX	((OPT_MAX)+6)
 
 #define KEXEC_ARCH_OPTIONS \
 	KEXEC_OPTIONS \
@@ -17,6 +18,7 @@
 	{ "lite",         0, NULL, OPT_LITE }, \
 	{ "port",         1, NULL, OPT_PORT }, \
 	{ "ramdisk",      1, NULL, OPT_INITRD }, \
+	{ "reuse-cmdline", 0, NULL, OPT_REUSE_CMDLINE }, \
 
 #define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR /* Only accept long arch options. */
 #define KEXEC_ALL_OPTIONS KEXEC_ARCH_OPTIONS
@@ -29,7 +31,8 @@ static const char arm64_opts_usage[] __attribute__ ((unused)) =
 "     --initrd=FILE         Use FILE as the kernel initial ramdisk.\n"
 "     --lite                Fast reboot, no memory integrity checks.\n"
 "     --port=ADDRESS        Purgatory output to port ADDRESS.\n"
-"     --ramdisk=FILE        Use FILE as the kernel initial ramdisk.\n";
+"     --ramdisk=FILE        Use FILE as the kernel initial ramdisk.\n"
+"     --reuse-cmdline       Use command line arg of primary kernel.\n";
 
 struct arm64_opts {
 	const char *command_line;
diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
index 391fec1fa161..34e4ebf1eb23 100644
--- a/kexec/arch/arm64/kexec-arm64.c
+++ b/kexec/arch/arm64/kexec-arm64.c
@@ -74,13 +74,18 @@ int arch_process_options(int argc, char **argv)
 		{ 0 }
 	};
 	int opt;
+	const char *append = NULL;
+	char *tmp_cmdline = NULL;
 
 	for (opt = 0; opt != -1; ) {
 		opt = getopt_long(argc, argv, short_options, options, 0);
 
 		switch (opt) {
 		case OPT_APPEND:
-			arm64_opts.command_line = optarg;
+			append = optarg;
+			break;
+		case OPT_REUSE_CMDLINE:
+			tmp_cmdline = get_command_line();
 			break;
 		case OPT_DTB:
 			arm64_opts.dtb = optarg;
@@ -99,6 +104,7 @@ int arch_process_options(int argc, char **argv)
 		}
 	}
 
+	arm64_opts.command_line = concat_cmdline(tmp_cmdline, append);
 	kexec_debug = 1; // FIXME: for debugging only.
 
 	dbgprintf("%s:%d: command_line: %s\n", __func__, __LINE__,
-- 
2.1.0




More information about the kexec mailing list