All of lore.kernel.org
 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/6][lxc][v3] lxc_restart: Add --statefile option
Date: Wed, 31 Mar 2010 00:07:11 -0700	[thread overview]
Message-ID: <20100331070711.GB23567@us.ibm.com> (raw)
In-Reply-To: <20100331070440.GA21570-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>


From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Date: Sat, 27 Mar 2010 00:08:17 -0700
Subject: [PATCH 2/6][lxc][v3] lxc_restart: Add --statefile 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 --statefile option to enable checkpointing and
restarting applications using USERCR.

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

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

diff --git a/src/lxc/lxc_restart.c b/src/lxc/lxc_restart.c
index 7db1d85..de4b421 100644
--- a/src/lxc/lxc_restart.c
+++ b/src/lxc/lxc_restart.c
@@ -38,13 +38,21 @@
 lxc_log_define(lxc_restart_ui, lxc_restart);
 
 static struct lxc_list defines;
+static char *statedir;
 
 static int my_checker(const struct lxc_arguments* args)
 {
-	if (!args->statefile) {
-		lxc_error(args, "no statefile specified");
-		return -1;
-	}
+	int d, f;
+	
+	/* make them boolean */
+	d = !!(statedir);
+	f = !!(args->statefile);
+
+        if (!(d ^ f)) {
+                lxc_error(args, "Must specify exactly one of --directory "
+                                "and --statefile options");
+                return -1;
+        }
 
 	return 0;
 }
@@ -52,8 +60,9 @@ static int my_checker(const struct lxc_arguments* args)
 static int my_parser(struct lxc_arguments* args, int c, char* arg)
 {
 	switch (c) {
-	case 'd': args->statefile = arg; break;
+	case 'd': statedir = arg; break;
 	case 'f': args->rcfile = arg; break;
+	case 'S': args->statefile = arg; break;
 	case 'p': args->flags = LXC_FLAG_PAUSE; break;
 	case 's': return lxc_config_define_add(&defines, arg);
 	}
@@ -66,21 +75,24 @@ static const struct option my_longopts[] = {
 	{"rcfile", required_argument, 0, 'f'},
 	{"pause", no_argument, 0, 'p'},
 	{"define", required_argument, 0, 's'},
+	{"statefile", required_argument, 0, 'S'},
 	LXC_COMMON_OPTIONS
 };
 
 static struct lxc_arguments my_args = {
 	.progname = "lxc-restart",
 	.help     = "\
---name=NAME --directory STATEFILE\n\
+--name=NAME --directory STATEFILE (deprecated)\n\
+\tlxc_restart --name=NAME --statefile=STATEFILE\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, deprecated)\n\
   -f, --rcfile=FILE Load configuration file FILE\n\
+  -i, --statefile=STATEFILE Load the application state from STATEFILE (libcr mode)\n\
   -s, --define KEY=VAL Assign VAL to configuration variable KEY\n",
 	.options  = my_longopts,
 	.parser   = my_parser,
@@ -90,6 +102,7 @@ Options :\n\
 int main(int argc, char *argv[])
 {
 	char *rcfile = NULL;
+	const char *statefile;
 	struct lxc_conf *conf;
 
 	lxc_list_init(&defines);
@@ -131,6 +144,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);
+	statefile = my_args.statefile;
+	if (statedir)
+		statefile = statedir;
+
+	return lxc_restart(my_args.name, statefile, conf, my_args.flags);
 }
-- 
1.6.6.1

  parent reply	other threads:[~2010-03-31  7:07 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-31  7:04 [PATCH 0/6][lxc][v3] Link LXC with USERCR Sukadev Bhattiprolu
     [not found] ` <20100331070440.GA21570-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-31  7:06   ` [PATCH 1/6][lxc][v3] Add --with-libcr configure option Sukadev Bhattiprolu
     [not found]     ` <20100331070633.GA23567-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-31  8:11       ` Michel Normand
2010-03-31 17:21         ` Sukadev Bhattiprolu
2010-03-31  7:07   ` Sukadev Bhattiprolu [this message]
     [not found]     ` <20100331070711.GB23567-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-31  8:10       ` [PATCH 2/6][lxc][v3] lxc_restart: Add --statefile option Michel Normand
2010-03-31  7:07   ` [PATCH 3/6][lxc][v3] lxc_checkpoint: " Sukadev Bhattiprolu
2010-03-31  7:08   ` [PATCH 4/6][lxc][v3] Move get_init_pid() into checkpoint.c Sukadev Bhattiprolu
     [not found]     ` <20100331070848.GD23567-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-31  8:17       ` Cedric Le Goater
2010-03-31  7:09   ` [PATCH 5/6][lxc][v3] Hook up lxc_restart() with app_restart() Sukadev Bhattiprolu
2010-03-31  7:10   ` [PATCH 6/6][lxc][v3] Hook up lxc_checkpoint() with app_checkpoint() Sukadev Bhattiprolu
     [not found]     ` <20100331071016.GF23567-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-31  8:08       ` Michel Normand
2010-03-31  8:18       ` Cedric Le Goater
2010-03-31  9:29   ` [PATCH 0/6][lxc][v3] Link LXC with USERCR Michel Normand
2010-03-31  9:38   ` Cedric Le Goater
     [not found]     ` <4BB31801.4000304-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2010-03-31 12:13       ` Cedric Le Goater
     [not found]         ` <4BB33C81.9070802-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2010-04-01  5:03           ` Sukadev Bhattiprolu
2010-03-31 13:58   ` Daniel Lezcano
     [not found]     ` <4BB35519.8080500-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2010-04-01  5:37       ` Oren Laadan
2010-03-31 16:31   ` Daniel Lezcano
2010-03-31 19:58   ` Daniel Lezcano
     [not found]     ` <4BB3A981.4020709-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2010-03-31 20:12       ` Serge E. Hallyn
     [not found]         ` <20100331201240.GA26773-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-31 20:22           ` Daniel Lezcano
2010-03-31 21:00           ` Daniel Lezcano
     [not found]             ` <4BB3B7E1.8080608-GANU6spQydw@public.gmane.org>
2010-03-31 21:23               ` Sukadev Bhattiprolu
     [not found]                 ` <20100331212359.GA18934-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-31 21:30                   ` Daniel Lezcano
     [not found]                     ` <4BB3BF02.7060402-GANU6spQydw@public.gmane.org>
2010-04-02  5:54                       ` Sukadev Bhattiprolu
2010-04-01  5:43               ` Oren Laadan

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=20100331070711.GB23567@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.