Skip to contentSkip to conversation

Fix app_checkpoint() return code

PATCH In review Sukadev Bhattiprolu 2 participants 3 messages Mar 31, 2010 – Apr 1, 2010 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Fix app_checkpoint() return code

From: Sukadev Bhattiprolu <[email protected]>
Date: Tue, 30 Mar 2010 18:59:10 -0700
Subject: [PATCH 1/2] Fix app_checkpoint() return code

Have app_checkpoint() return the return value from the system call so callers find some useful information. Have main() can convert the return value into a suitable exit status.

---
 checkpoint-main.c |    4 +++-
 checkpoint.c      |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
checkpoint-main.c +3 -1
index f6faa32..bac65cc 100644
@@ -145,6 +145,7 @@ static void parse_args(struct app_checkpoint_args *args, int argc, char *argv[])
 
 int main(int argc, char *argv[])
 {
+	int ret;
 	struct app_checkpoint_args args;
 	unsigned long flags = 0;
 	pid_t pid;
@@ -167,5 +168,6 @@ int main(int argc, char *argv[])
 	if (!args.container)
 		flags |= CHECKPOINT_SUBTREE;
 
-	return app_checkpoint(pid, flags, &args);
+	ret = app_checkpoint(pid, flags, &args);
+	return (ret > 0) ? 0 : 1;
 }
checkpoint.c +1 -1
index e3a1ce8..e0290c9 100644
@@ -55,5 +55,5 @@ int app_checkpoint(int pid, unsigned long flags,
 		ckpt_err("checkpoint id %d\n", ret);
 	}
 
-	return (ret > 0 ? 0 : 1);
+	return ret;
 }
Signature · 1 line
1.6.6.1

A message that is not in the archive (sent off-list or not yet received): 20100331065443.GA21065-r/[email protected]

#2 lore raw

PATCH 2/2 Add keep_frozen field to struct app_restart_args

From: Sukadev Bhattiprolu <[email protected]>
Date: Tue, 30 Mar 2010 23:14:53 -0700
Subject: [PATCH 2/2] Add keep_frozen field to struct app_restart_args

Add a field, keep_frozen that callers of app_restart() can use to leave the application frozen after restart. When this field is set, have app_restart() set the RESTART_FROZEN flag to sys_restart().

TODO:
For now, this field will be used in LXC containers. A follow-on patch would add a command line option to /bin/restart to let users select this behavior.

---
 app-checkpoint.h |    3 +++
 restart.c        |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)
app-checkpoint.h +3 -0
index f740085..d2455f3 100644
@@ -1,3 +1,5 @@
+#include <linux/checkpoint.h>
+#include <linux/checkpoint_hdr.h>
 
 struct app_checkpoint_args {
 	int outfd;
@@ -19,6 +21,7 @@ struct app_restart_args {
 	int show_status;
 	int copy_status;
 	char *freezer;
+	int keep_frozen;
 	int infd;
 	int klogfd;
 	int ulogfd;
restart.c +1 -1
index 5408152..d5fee0b 100644
@@ -914,7 +914,7 @@ static int ckpt_coordinator(struct ckpt_ctx *ctx)
 	if (ckpt_probe_child(root_pid, "root task") < 0)
 		exit(1);
 
-	if (ctx->args->freezer)
+	if (ctx->args->freezer || ctx->args->keep_frozen)
 		flags |= RESTART_FROZEN;
 	if (ctx->args->keep_lsm)
 		flags |= RESTART_KEEP_LSM;
Signature · 1 line
1.6.6.1
#3 lore raw
In reply to a message not in the archive

Both patches applies in user-cr:ckpt-v20-dev.

Oren.

Quoted 45 lines · Sukadev Bhattiprolu

From: Sukadev Bhattiprolu <[email protected]>
Date: Tue, 30 Mar 2010 18:59:10 -0700
Subject: [PATCH 1/2] Fix app_checkpoint() return code

Have app_checkpoint() return the return value from the system call so callers find some useful information. Have main() can convert the return value into a suitable exit status.

---
 checkpoint-main.c |    4 +++-
 checkpoint.c      |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
checkpoint-main.c +3 -1
index f6faa32..bac65cc 100644
@@ -145,6 +145,7 @@ static void parse_args(struct app_checkpoint_args *args, int argc, char *argv[])
 
 int main(int argc, char *argv[])
 {
+	int ret;
 	struct app_checkpoint_args args;
 	unsigned long flags = 0;
 	pid_t pid;
@@ -167,5 +168,6 @@ int main(int argc, char *argv[])
 	if (!args.container)
 		flags |= CHECKPOINT_SUBTREE;
 
-	return app_checkpoint(pid, flags, &args);
+	ret = app_checkpoint(pid, flags, &args);
+	return (ret > 0) ? 0 : 1;
 }
checkpoint.c +1 -1
index e3a1ce8..e0290c9 100644
@@ -55,5 +55,5 @@ int app_checkpoint(int pid, unsigned long flags,
 		ckpt_err("checkpoint id %d\n", ret);
 	}
 
-	return (ret > 0 ? 0 : 1);
+	return ret;
 }