[CRIU] [PATCH]v2 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:48:27 PDT 2013


On 02.10.2013 19:19, Ruslan Kuprieiev wrote:
> 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>

v2: Fixed my mistakes.

Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
-------------- next part --------------
---
diff --git a/cr-service.c b/cr-service.c
index 3c41658..e9b5557 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -111,7 +111,7 @@ static int setup_dump_from_req(int sk, CriuOpts *req)
 	log_closedir();
 
 	/* initiate log file in imgs dir */
-	opts.output = "./dump.log";
+	opts.output = req->log_file;
 
 	log_set_loglevel(req->log_level);
 	if (log_init(opts.output) == -1) {
@@ -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..9794ddf 100644
--- a/include/log.h
+++ b/include/log.h
@@ -59,4 +59,7 @@ extern int write_pidfile(char *pfname, int pid);
 #define pr_perror(fmt, ...)							\
 	pr_err(fmt ": %m\n", ##__VA_ARGS__)
 
+#define DEFAULT_DUMP_LOG_FILENAME "dump.log"
+#define DEFAULT_RESTORE_LOG_FILENAME "restore.log"
+
 #endif /* __CR_LOG_H__ */
diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
index 3fe07e0..db55d48 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 string log_file	= 9;
+	optional int32 log_level	= 10 [default = 2];
 }
 
 message criu_dump_resp {


More information about the CRIU mailing list