From: Daniel Lezcano Date: Thu, 28 May 2009 10:10:50 +0000 (+0200) Subject: save the config file in the statefile directory X-Git-Tag: lxc_0_6_3~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f8b55d5cccd8826e7710d98dd5680637791a481;p=thirdparty%2Flxc.git save the config file in the statefile directory Save the configuration file in the statefile directory so it can be re-created at restart time. Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/lxc_checkpoint.c b/src/lxc/lxc_checkpoint.c index feac55dd9..0ca35fb93 100644 --- a/src/lxc/lxc_checkpoint.c +++ b/src/lxc/lxc_checkpoint.c @@ -20,7 +20,9 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define _GNU_SOURCE #include +#include #include #include #include @@ -77,6 +79,37 @@ Options :\n\ .rcfile = NULL, }; +static int save_config_file(const char *name, const char *dir) +{ + char *src, *dst; + int ret; + + if (!asprintf(&src, LXCPATH "/%s/config", name)) { + ERROR("failed to allocate memory"); + return -1; + } + + if (access(src, F_OK)) { + free(src); + return 0; + } + + if (!asprintf(&dst, "%s/config", dir)) { + ERROR("failed to allocate memory"); + free(src); + return -1; + } + + ret = lxc_copy_file(src, dst); + if (ret) + ERROR("failed to copy '%s' to '%s'", src, dst); + + free(src); + free(dst); + + return ret; +} + int main(int argc, char *argv[]) { int ret = -1; @@ -90,6 +123,12 @@ int main(int argc, char *argv[]) if (ret) return ret; + ret = save_config_file(my_args.name, my_args.statefile); + if (ret) { + ERROR("failed to save the configuration"); + return ret; + } + ret = lxc_checkpoint(my_args.name, -1, 0); if (ret) { ERROR("failed to checkpoint '%s'", my_args.name);