Linux Container Development
 help / color / mirror / Atom feed
From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: dlezcano-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org
Cc: Containers
	<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
	clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org
Subject: [PATCH 2/5][lxc] lxc_restart: Add --image option
Date: Thu, 18 Mar 2010 23:40:46 -0700	[thread overview]
Message-ID: <20100319064046.GC25732@us.ibm.com> (raw)
In-Reply-To: <20100319063912.GA25732-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>


From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Date: Wed, 10 Mar 2010 21:59:39 -0800
Subject: [PATCH 2/5][lxc] lxc_restart: Add --image option

The existing --directory option to lxc_restart expects the checkpoint state
to be a directory. USERCR however uses a single regular file to store the
checkpoint image. So add a --image option to enable checkpointing and
restarting applications using USERCR.

Depending on how the application was checkpointed, users should specify
either --image=CHECKPOINT-IMAGE or the --directory=STATEFILE option (but not
both).

Signed-off-by: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
---
 src/lxc/arguments.h   |    1 +
 src/lxc/lxc_restart.c |   29 ++++++++++++++++++++++-------
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/src/lxc/arguments.h b/src/lxc/arguments.h
index 3bc027d..30953ee 100644
--- a/src/lxc/arguments.h
+++ b/src/lxc/arguments.h
@@ -45,6 +45,7 @@ struct lxc_arguments {
 	int daemonize;
 	const char *rcfile;
 	const char *statefile;
+	const char *imagefile;
 
 	/* for lxc-checkpoint */
 	int flags;
diff --git a/src/lxc/lxc_restart.c b/src/lxc/lxc_restart.c
index 7db1d85..39f7ea8 100644
--- a/src/lxc/lxc_restart.c
+++ b/src/lxc/lxc_restart.c
@@ -41,10 +41,17 @@ static struct lxc_list defines;
 
 static int my_checker(const struct lxc_arguments* args)
 {
-	if (!args->statefile) {
-		lxc_error(args, "no statefile specified");
-		return -1;
-	}
+	int i, s;
+	
+	/* make them boolean */
+	i = !!(args->imagefile);
+	s = !!(args->statefile);
+
+        if (!(i ^ s)) {
+                lxc_error(args, "Must specify exactly one of --directory "
+                                "and --image options");
+                return -1;
+        }
 
 	return 0;
 }
@@ -54,6 +61,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
 	switch (c) {
 	case 'd': args->statefile = arg; break;
 	case 'f': args->rcfile = arg; break;
+	case 'i': args->imagefile = arg; break;
 	case 'p': args->flags = LXC_FLAG_PAUSE; break;
 	case 's': return lxc_config_define_add(&defines, arg);
 	}
@@ -66,6 +74,7 @@ static const struct option my_longopts[] = {
 	{"rcfile", required_argument, 0, 'f'},
 	{"pause", no_argument, 0, 'p'},
 	{"define", required_argument, 0, 's'},
+	{"image", required_argument, 0, 'i'},
 	LXC_COMMON_OPTIONS
 };
 
@@ -73,14 +82,16 @@ static struct lxc_arguments my_args = {
 	.progname = "lxc-restart",
 	.help     = "\
 --name=NAME --directory STATEFILE\n\
+\tlxc_restart --name=NAME --image CHECKPOINT-IMAGE\n\
 \n\
 lxc-restart restarts from STATEFILE the NAME container\n\
 \n\
 Options :\n\
   -n, --name=NAME      NAME for name of the container\n\
   -p, --pause          do not release the container after the restart\n\
-  -d, --directory=STATEFILE for name of statefile\n\
+  -d, --directory=STATEFILE for name of statefile(legacy mode)\n\
   -f, --rcfile=FILE Load configuration file FILE\n\
+  -i, --image=FILE Load the application state from FILE(user-cr mode)\n\
   -s, --define KEY=VAL Assign VAL to configuration variable KEY\n",
 	.options  = my_longopts,
 	.parser   = my_parser,
@@ -90,6 +101,7 @@ Options :\n\
 int main(int argc, char *argv[])
 {
 	char *rcfile = NULL;
+	const char *image = NULL;
 	struct lxc_conf *conf;
 
 	lxc_list_init(&defines);
@@ -131,6 +143,9 @@ int main(int argc, char *argv[])
 	if (lxc_config_define_load(&defines, conf))
 		return -1;
 
-	return lxc_restart(my_args.name, my_args.statefile, conf,
-			   my_args.flags);
+	image = my_args.imagefile;
+	if (my_args.statefile)
+		image = my_args.statefile;
+
+	return lxc_restart(my_args.name, image, conf, my_args.flags);
 }
-- 
1.6.6.1

  parent reply	other threads:[~2010-03-19  6:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-19  6:39 [RFC][PATCH 0/5][lxc]: Link with USERCR Sukadev Bhattiprolu
     [not found] ` <20100319063912.GA25732-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-19  6:40   ` [PATCH 1/5][lxc] Enable static linking of some lxc binaries Sukadev Bhattiprolu
     [not found]     ` <20100319064024.GB25732-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-22 14:44       ` Daniel Lezcano
2010-03-19  6:40   ` Sukadev Bhattiprolu [this message]
     [not found]     ` <20100319064046.GC25732-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-22 14:45       ` [PATCH 2/5][lxc] lxc_restart: Add --image option Daniel Lezcano
     [not found]         ` <4BA78276.2040308-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2010-03-24 19:48           ` Sukadev Bhattiprolu
     [not found]             ` <20100324194851.GD20031-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-24 20:53               ` Daniel Lezcano
2010-03-19  6:41   ` [PATCH 3/5][lxc] lxc_checkpoint: " Sukadev Bhattiprolu
2010-03-19  6:41   ` [PATCH 4/5][lxc] Hook up lxc_restart() with app_restart() Sukadev Bhattiprolu
     [not found]     ` <20100319064121.GE25732-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-22 14:48       ` Daniel Lezcano
2010-03-19  6:41   ` [PATCH 5/5][lxc] Hook up lxc_checkpoint() with app_checkpoint() Sukadev Bhattiprolu
     [not found]     ` <20100319064141.GF25732-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-22 14:44       ` Daniel Lezcano
     [not found]         ` <4BA78262.6050109-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2010-03-24 19:35           ` Sukadev Bhattiprolu
     [not found]             ` <20100324193537.GB20031-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-24 20:51               ` Daniel Lezcano
2010-03-19 10:44   ` [RFC][PATCH 0/5][lxc]: Link with USERCR Michel Normand
2010-03-24 19:22     ` Sukadev Bhattiprolu
2010-03-22 14:45   ` Daniel Lezcano
     [not found]     ` <4BA7826D.10706-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2010-03-24 19:27       ` Oren Laadan
2010-03-24 19:47       ` Sukadev Bhattiprolu
     [not found]         ` <20100324194744.GC20031-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-24 20:52           ` Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100319064046.GC25732@us.ibm.com \
    --to=sukadev-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
    --cc=clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=dlezcano-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox