[CRIU] [PATCH] rpc: add log_file field to opts, add defaults toi log.h and use them where needed

Ruslan Kuprieiev kupruser at gmail.com
Wed Oct 2 08:19:46 PDT 2013


Hi!

As we are to add new types of requests to rpc, it would be in handy to 
have ability to set logfile name. So lets add log_file field to rpc 
opts, and set DEFAULT_***_LOG_FILENAME if log_file == NULL.

Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
-------------- next part --------------
diff --git a/cr-service.c b/cr-service.c
index 3c41658..f54a46e 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -111,14 +111,14 @@ static int setup_dump_from_req(int sk, CriuOpts *req)
 	log_closedir();
 
 	/* initiate log file in imgs dir */
-	opts.output = "./dump.log";
-
-	log_set_loglevel(req->log_level);
+	opts.output = req->log_file;
 	if (log_init(opts.output) == -1) {
 		pr_perror("Can't initiate log.");
 		return -1;
 	}
 
+	log_set_loglevel(req->log_level);
+
 	/* checking dump flags from client */
 	if (req->has_leave_running && req->leave_running)
 		opts.final_state = TASK_ALIVE;
@@ -150,6 +150,9 @@ static int dump_using_req(int sk, CriuOpts *req)
 {
 	bool success = false;
 
+	if (!req->log_file)
+		req->log_file = DEFAULT_DUMP_LOG_FILENAME;
+
 	if (setup_dump_from_req(sk, req) == -1) {
 		pr_perror("Arguments treating fail");
 		goto exit;
diff --git a/include/log.h b/include/log.h
index 17f624b..a74bd93 100644
--- a/include/log.h
+++ b/include/log.h
@@ -3,6 +3,9 @@
 
 #include "log-levels.h"
 
+#define DEFAULT_DUMP_LOG_FILENAME	"dump.log"
+#define DEFAULT_RESTORE_LOG_FILENAME	"restore.log"
+
 extern int log_init(const char *output);
 extern void log_fini(void);
 extern int log_init_by_pid(void);
diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
index 27bc993..37f2f41 100644
--- a/protobuf/rpc.proto
+++ b/protobuf/rpc.proto
@@ -8,7 +8,8 @@ message criu_opts {
 	optional bool evasive_devices	= 6;
 	optional bool shell_job		= 7;
 	optional bool file_locks	= 8;
-	optional int32 log_level	= 9 [default = 2];
+	optional bool log_file		= 9;
+	optional int32 log_level	= 10 [default = 2];
 }
 
 message criu_dump_resp {


More information about the CRIU mailing list