diff mbox series

[v2,06/30] discover: Add --debug to kexec

Message ID 7ca198d87bd13d441627ca6789fd198da33c168f.1533230644.git.geoff@infradead.org
State Accepted
Headers show
Series [v2,01/30] docker: Add libfdt-dev | expand

Commit Message

Geoff Levand Aug. 2, 2018, 5:29 p.m. UTC
If verbose logging is enabled then add '--debug' to the kexec command line.
Adds a new routine pb_log_get_debug() that can be used to query the log
debug state.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 discover/boot.c | 16 ++++++++++------
 lib/log/log.c   |  5 +++++
 lib/log/log.h   |  1 +
 3 files changed, 16 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/discover/boot.c b/discover/boot.c
index 7faec9f..3de7d28 100644
--- a/discover/boot.c
+++ b/discover/boot.c
@@ -62,7 +62,7 @@  static int kexec_load(struct boot_task *boot_task)
 	struct process *process;
 	char *s_initrd = NULL;
 	char *s_args = NULL;
-	const char *argv[7];
+	const char *argv[8];
 	char *s_dtb = NULL;
 	const char **p;
 	int result;
@@ -107,27 +107,31 @@  static int kexec_load(struct boot_task *boot_task)
 	*p++ = pb_system_apps.kexec;	/* 1 */
 	*p++ = "-l";			/* 2 */
 
+	if (pb_log_get_debug()) {
+		*p++ = "--debug";	/* 3 */
+	}
+
 	if (local_initrd) {
 		s_initrd = talloc_asprintf(boot_task, "--initrd=%s",
 				local_initrd);
 		assert(s_initrd);
-		*p++ = s_initrd;	 /* 3 */
+		*p++ = s_initrd;	 /* 4 */
 	}
 
 	if (local_dtb) {
 		s_dtb = talloc_asprintf(boot_task, "--dtb=%s",
 						local_dtb);
 		assert(s_dtb);
-		*p++ = s_dtb;		 /* 4 */
+		*p++ = s_dtb;		 /* 5 */
 	}
 
 	s_args = talloc_asprintf(boot_task, "--append=%s",
 				boot_task->args ?: "\"\"");
 	assert(s_args);
-	*p++ = s_args;		/* 5 */
+	*p++ = s_args;			/* 6 */
 
-	*p++ = local_image;		/* 6 */
-	*p++ = NULL;			/* 7 */
+	*p++ = local_image;		/* 7 */
+	*p++ = NULL;			/* 8 */
 
 	result = process_run_sync(process);
 	if (result) {
diff --git a/lib/log/log.c b/lib/log/log.c
index 0b145e0..5466d81 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -88,6 +88,11 @@  void pb_log_set_debug(bool _debug)
 	debug = _debug;
 }
 
+bool pb_log_get_debug(void)
+{
+	return debug;
+}
+
 FILE *pb_log_get_stream(void)
 {
 	static FILE *null_stream;
diff --git a/lib/log/log.h b/lib/log/log.h
index 2d4fd91..c2ad58e 100644
--- a/lib/log/log.h
+++ b/lib/log/log.h
@@ -26,6 +26,7 @@  void __pb_log_init(FILE *stream, bool debug);
 #endif
 
 void pb_log_set_debug(bool debug);
+bool pb_log_get_debug(void);
 FILE *pb_log_get_stream(void);
 
 #endif /* _LOG_H */