]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
add a statefile directory parameter
authorDaniel Lezcano <dlezcano@fr.ibm.com>
Thu, 28 May 2009 10:10:50 +0000 (12:10 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Thu, 28 May 2009 10:10:50 +0000 (12:10 +0200)
add a statefile directory parameter in order to save some
lxc informations a checkpoint.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/arguments.h
src/lxc/lxc_checkpoint.c

index 3fdc342e967b89d255d1087c2fb6b510b67ec089..9b7fbf5542a86dd1d3cbb8ca7a43ffefa2cf9160 100644 (file)
@@ -43,6 +43,7 @@ struct lxc_arguments {
        char *log_priority;
        int quiet;
        const char *rcfile;
+       const char *statefile;
 
        /* for lxc-checkpoint */
        int kill;
index 767549d0efcfa0f5c005efad1698016a63b5fce6..feac55dd9fe18429a708b6b5715a33cd9865baae 100644 (file)
 #include <lxc.h>
 #include "arguments.h"
 
+lxc_log_define(lxc_checkpoint, lxc);
+
 static int my_checker(const struct lxc_arguments* args)
 {
-       if (!args->argc) {
-               lxc_error(args, "missing STATEFILE filename !");
+       if (!args->statefile) {
+               lxc_error(args, "no statefile specified");
                return -1;
        }
+
        return 0;
 }
 
@@ -42,6 +45,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
        switch (c) {
        case 'k': args->kill = 1; break;
        case 'p': args->pause = 1; break;
+       case 'd': args->statefile = arg; break;
        }
        return 0;
 }
@@ -49,6 +53,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
 static const struct option my_longopts[] = {
        {"kill", no_argument, 0, 'k'},
        {"pause", no_argument, 0, 'p'},
+       {"directory", required_argument, 0, 'd'},
        LXC_COMMON_OPTIONS
 };
 
@@ -62,7 +67,8 @@ lxc-checkpoint checkpoints in STATEFILE file the NAME container\n\
 Options :\n\
   -n, --name=NAME      NAME for name of the container\n\
   -k, --kill           stop the container after checkpoint\n\
-  -p, --pause          don't unfreeze the container after the checkpoint\n",
+  -p, --pause          don't unfreeze the container after the checkpoint\n\
+  -d, --directory      directory to store the statefile\n",
 
        .options  = my_longopts,
        .parser   = my_parser,
@@ -85,8 +91,12 @@ int main(int argc, char *argv[])
                return ret;
 
        ret = lxc_checkpoint(my_args.name, -1, 0);
-       if (ret)
+       if (ret) {
+               ERROR("failed to checkpoint '%s'", my_args.name);
                return ret;
+       }
+
+       INFO("'%s' checkpointed", my_args.name);
 
        return ret;
 }