[CRIU] [RESEND PATCH v3 1/7] Add log_level to the global options structure

Adrian Reber adrian at lisas.de
Tue Jul 10 12:39:24 MSK 2018


From: Adrian Reber <areber at 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 at redhat.com>
---
 criu/crtools.c            | 10 +++++-----
 criu/include/cr_options.h |  1 +
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/criu/crtools.c b/criu/crtools.c
index 3215536..d7c77b0 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -80,6 +80,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)
@@ -274,7 +275,6 @@ int main(int argc, char *argv[], char *envp[])
 	int opt = 0, idx;
 	int global_cfg_argc = 0, user_cfg_argc = 0;
 	int state = PARSING_GLOBAL_CONF;
-	int log_level = DEFAULT_LOGLEVEL;
 	char *imgs_dir = ".";
 
 #define BOOL_OPT(OPT_NAME, SAVE_TO) \
@@ -502,11 +502,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;
@@ -801,7 +801,7 @@ 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;
diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h
index f0e84c1..1365b2e 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;
-- 
1.8.3.1



More information about the CRIU mailing list