[1/4] Add log_level to the global options structure

Submitted by Adrian Reber on March 20, 2018, 4:55 p.m.

Details

Message ID 20180320165510.13126-2-adrian@lisas.de
State New
Series "Series without cover letter"
Headers show

Commit Message

Adrian Reber March 20, 2018, 4:55 p.m.
From: Adrian Reber <areber@redhat.com>

For the upcoming RPC configuration file support the log_level needs to
be part of the global options structure, to be able to set it from the
RPC code path.

Signed-off-by: Adrian Reber <areber@redhat.com>
---
 criu/crtools.c            | 12 ++++++------
 criu/include/cr_options.h |  1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/crtools.c b/criu/crtools.c
index 17e16ce86..90cbb6d6d 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -82,6 +82,7 @@  void init_opts(void)
 	opts.timeout = DEFAULT_TIMEOUT;
 	opts.empty_ns = 0;
 	opts.status_fd = -1;
+	opts.log_level = DEFAULT_LOGLEVEL;
 }
 
 static int parse_join_ns(const char *ptr)
@@ -435,7 +436,6 @@  int main(int argc, char *argv[], char *envp[])
 	int opt = 0, idx, help_or_configs;
 	int first_count = 1, second_count = 1;
 	int state = PARSING_GLOBAL_CONF;
-	int log_level = DEFAULT_LOGLEVEL;
 	char *imgs_dir = ".";
 
 #define BOOL_OPT(OPT_NAME, SAVE_TO) \
@@ -666,11 +666,11 @@  int main(int argc, char *argv[], char *envp[])
 			if (optarg) {
 				if (optarg[0] == 'v')
 					/* handle -vvvvv */
-					log_level += strlen(optarg) + 1;
+					opts.log_level += strlen(optarg) + 1;
 				else
-					log_level = atoi(optarg);
+					opts.log_level = atoi(optarg);
 			} else
-				log_level++;
+				opts.log_level++;
 			break;
 		case 1043: {
 			int fd;
@@ -959,11 +959,11 @@  int main(int argc, char *argv[], char *envp[])
 		return 1;
 	}
 
-	log_set_loglevel(log_level);
+	log_set_loglevel(opts.log_level);
 
 	if (log_init(opts.output))
 		return 1;
-	libsoccr_set_log(log_level, soccr_print_on_level);
+	libsoccr_set_log(opts.log_level, soccr_print_on_level);
 	compel_log_init(vprint_on_level, log_get_loglevel());
 
 	print_versions();
diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h
index f0e84c1a1..1365b2e32 100644
--- a/criu/include/cr_options.h
+++ b/criu/include/cr_options.h
@@ -123,6 +123,7 @@  struct cr_options {
 	bool			orphan_pts_master;
 	int			check_only;
 	int			remote;
+	int			log_level;
 };
 
 extern struct cr_options opts;