All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Neuling <mikey@neuling.org>
To: kexec@lists.infradead.org
Cc: linuxppc-dev@ozlabs.org, horms@verge.net.au,
	Fastboot mailing list <fastboot@lists.osdl.org>,
	miltonm@bga.com
Subject: [PATCH 1/2] kexec: Added generic --reuseinitrd option
Date: Mon, 23 Apr 2007 18:30:15 +1000	[thread overview]
Message-ID: <13112.1177317015@neuling.org> (raw)
In-Reply-To: <5129.1176956949@neuling.org>

Adds a generic --reuseinitrd option and performs some sanity checks on
it.  Can be used with the retain_initrd kernel option.

---
This series attempts to address some of Milton's concerns.

 kexec/kexec.c |   33 +++++++++++++++++++++++++++++++++
 kexec/kexec.h |    2 ++
 2 files changed, 35 insertions(+)

Index: kexec-tools-testing/kexec/kexec.c
===================================================================
--- kexec-tools-testing.orig/kexec/kexec.c
+++ kexec-tools-testing/kexec/kexec.c
@@ -748,6 +748,7 @@ void usage(void)
 	       "                      load code into.\n"
 	       "     --mem-max=<addr> Specify the highest memory address to\n"
 	       "                      load code into.\n"
+	       "     --reuseinird     Reuse initrd from first boot.\n"
 	       "\n"
 	       "Supported kernel file types and options: \n");
 	for (i = 0; i < file_types; i++) {
@@ -772,6 +773,29 @@ static int kexec_loaded(void)
 	return ret;
 }
 
+/* check we retained the initrd */
+void check_reuse_initrd(void)
+{
+	FILE * fp;
+	char * line = NULL;
+	size_t len = 0;
+	ssize_t read;
+
+	fp = fopen("/proc/cmdline", "r");
+	if (fp == NULL)
+		die("unable to open /proc/cmdline\n");
+	read = getline(&line, &len, fp);
+	if (strstr(line, "retain_initrd") == NULL)
+		die("unrecoverable error: current boot didn't "
+		    "retain the initrd for reuse.\n");
+}
+
+/* Arch hook for reuse_initrd */
+void __attribute__((weak)) arch_reuse_initrd(void)
+{
+	die("--reuseinitrd not implemented on this architecture\n");
+}
+
 int main(int argc, char *argv[])
 {
 	int do_load = 1;
@@ -780,6 +804,7 @@ int main(int argc, char *argv[])
 	int do_sync = 1;
 	int do_ifdown = 0;
 	int do_unload = 0;
+	int do_reuse_initrd = 0;
 	unsigned long kexec_flags = 0;
 	char *type = 0;
 	char *endptr;
@@ -860,6 +885,9 @@ int main(int argc, char *argv[])
 				return 1;
 			}
 			break;
+		case OPT_REUSE_INITRD:
+			do_reuse_initrd = 1;
+			break;
 		default:
 			break;
 		}
@@ -890,6 +918,11 @@ int main(int argc, char *argv[])
 		}
 	}
 
+	if (do_reuse_initrd){
+		check_reuse_initrd();
+		arch_reuse_initrd();
+	}
+
 	if (do_unload) {
 		result = k_unload(kexec_flags);
 	}
Index: kexec-tools-testing/kexec/kexec.h
===================================================================
--- kexec-tools-testing.orig/kexec/kexec.h
+++ kexec-tools-testing/kexec/kexec.h
@@ -163,6 +163,7 @@ extern int file_types;
 #define OPT_MEM_MIN             256
 #define OPT_MEM_MAX             257
 #define OPT_MAX			258
+#define OPT_REUSE_INITRD	259
 #define KEXEC_OPTIONS \
 	{ "help",		0, 0, OPT_HELP }, \
 	{ "version",		0, 0, OPT_VERSION }, \
@@ -175,6 +176,7 @@ extern int file_types;
 	{ "load-panic",         0, 0, OPT_PANIC }, \
 	{ "mem-min",		1, 0, OPT_MEM_MIN }, \
 	{ "mem-max",		1, 0, OPT_MEM_MAX }, \
+	{ "reuseinitrd",	0, 0, OPT_REUSE_INITRD }, \
 
 #define KEXEC_OPT_STR "hvdfxluet:p"
 




_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

WARNING: multiple messages have this Message-ID (diff)
From: Michael Neuling <mikey@neuling.org>
To: kexec@lists.infradead.org
Cc: linuxppc-dev@ozlabs.org, horms@verge.net.au,
	Fastboot mailing list <fastboot@lists.osdl.org>,
	miltonm@bga.com
Subject: [PATCH 1/2] kexec: Added generic --reuseinitrd option
Date: Mon, 23 Apr 2007 18:30:15 +1000	[thread overview]
Message-ID: <13112.1177317015@neuling.org> (raw)
In-Reply-To: <5129.1176956949@neuling.org>

Adds a generic --reuseinitrd option and performs some sanity checks on
it.  Can be used with the retain_initrd kernel option.

---
This series attempts to address some of Milton's concerns.

 kexec/kexec.c |   33 +++++++++++++++++++++++++++++++++
 kexec/kexec.h |    2 ++
 2 files changed, 35 insertions(+)

Index: kexec-tools-testing/kexec/kexec.c
===================================================================
--- kexec-tools-testing.orig/kexec/kexec.c
+++ kexec-tools-testing/kexec/kexec.c
@@ -748,6 +748,7 @@ void usage(void)
 	       "                      load code into.\n"
 	       "     --mem-max=<addr> Specify the highest memory address to\n"
 	       "                      load code into.\n"
+	       "     --reuseinird     Reuse initrd from first boot.\n"
 	       "\n"
 	       "Supported kernel file types and options: \n");
 	for (i = 0; i < file_types; i++) {
@@ -772,6 +773,29 @@ static int kexec_loaded(void)
 	return ret;
 }
 
+/* check we retained the initrd */
+void check_reuse_initrd(void)
+{
+	FILE * fp;
+	char * line = NULL;
+	size_t len = 0;
+	ssize_t read;
+
+	fp = fopen("/proc/cmdline", "r");
+	if (fp == NULL)
+		die("unable to open /proc/cmdline\n");
+	read = getline(&line, &len, fp);
+	if (strstr(line, "retain_initrd") == NULL)
+		die("unrecoverable error: current boot didn't "
+		    "retain the initrd for reuse.\n");
+}
+
+/* Arch hook for reuse_initrd */
+void __attribute__((weak)) arch_reuse_initrd(void)
+{
+	die("--reuseinitrd not implemented on this architecture\n");
+}
+
 int main(int argc, char *argv[])
 {
 	int do_load = 1;
@@ -780,6 +804,7 @@ int main(int argc, char *argv[])
 	int do_sync = 1;
 	int do_ifdown = 0;
 	int do_unload = 0;
+	int do_reuse_initrd = 0;
 	unsigned long kexec_flags = 0;
 	char *type = 0;
 	char *endptr;
@@ -860,6 +885,9 @@ int main(int argc, char *argv[])
 				return 1;
 			}
 			break;
+		case OPT_REUSE_INITRD:
+			do_reuse_initrd = 1;
+			break;
 		default:
 			break;
 		}
@@ -890,6 +918,11 @@ int main(int argc, char *argv[])
 		}
 	}
 
+	if (do_reuse_initrd){
+		check_reuse_initrd();
+		arch_reuse_initrd();
+	}
+
 	if (do_unload) {
 		result = k_unload(kexec_flags);
 	}
Index: kexec-tools-testing/kexec/kexec.h
===================================================================
--- kexec-tools-testing.orig/kexec/kexec.h
+++ kexec-tools-testing/kexec/kexec.h
@@ -163,6 +163,7 @@ extern int file_types;
 #define OPT_MEM_MIN             256
 #define OPT_MEM_MAX             257
 #define OPT_MAX			258
+#define OPT_REUSE_INITRD	259
 #define KEXEC_OPTIONS \
 	{ "help",		0, 0, OPT_HELP }, \
 	{ "version",		0, 0, OPT_VERSION }, \
@@ -175,6 +176,7 @@ extern int file_types;
 	{ "load-panic",         0, 0, OPT_PANIC }, \
 	{ "mem-min",		1, 0, OPT_MEM_MIN }, \
 	{ "mem-max",		1, 0, OPT_MEM_MAX }, \
+	{ "reuseinitrd",	0, 0, OPT_REUSE_INITRD }, \
 
 #define KEXEC_OPT_STR "hvdfxluet:p"
 

  parent reply	other threads:[~2007-04-23  8:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-18  7:26 [PATCH] kexec-tools ppc64: add --reuseinitrd option Michael Neuling
2007-04-19  4:29 ` Michael Neuling
2007-04-19  4:29   ` Michael Neuling
2007-04-20  5:58   ` Milton Miller
2007-04-20  5:58     ` Milton Miller
2007-04-20  7:23     ` Michael Neuling
2007-04-20  7:23       ` Michael Neuling
2007-04-20  7:42       ` Milton Miller
2007-04-20  7:42         ` Milton Miller
2007-04-23  8:30   ` Michael Neuling [this message]
2007-04-23  8:30     ` [PATCH 1/2] kexec: Added generic " Michael Neuling
2007-04-23  8:30     ` [PATCH 2/2] kexec ppc64: Add arch specific --reuseinitrd hooks Michael Neuling
2007-04-23  8:30       ` Michael Neuling
2007-04-27  4:53     ` [PATCH 1/2] kexec: Added generic --reuseinitrd option Michael Neuling
2007-04-27  4:53       ` [PATCH 2/2] kexec ppc64: Add arch specific --reuseinitrd hooks Michael Neuling
2007-05-01  2:25       ` [PATCH 1/2] kexec: Added generic --reuseinitrd option Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13112.1177317015@neuling.org \
    --to=mikey@neuling.org \
    --cc=fastboot@lists.osdl.org \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=miltonm@bga.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.