Commit 3f8b55d5 by Daniel Lezcano

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: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 6b201d02
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define _GNU_SOURCE
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <libgen.h> #include <libgen.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
...@@ -77,6 +79,37 @@ Options :\n\ ...@@ -77,6 +79,37 @@ Options :\n\
.rcfile = NULL, .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 main(int argc, char *argv[])
{ {
int ret = -1; int ret = -1;
...@@ -90,6 +123,12 @@ int main(int argc, char *argv[]) ...@@ -90,6 +123,12 @@ int main(int argc, char *argv[])
if (ret) if (ret)
return 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); ret = lxc_checkpoint(my_args.name, -1, 0);
if (ret) { if (ret) {
ERROR("failed to checkpoint '%s'", my_args.name); ERROR("failed to checkpoint '%s'", my_args.name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment