Commit 4fcc0112 by Daniel Lezcano

create the container with an empty configuration

Fix the code to not fail when the specified configuration file is empty. Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 6203de18
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include "confile.h" #include "confile.h"
#include "arguments.h" #include "arguments.h"
lxc_log_define(lxc_create, lxc);
static int my_parser(struct lxc_arguments* args, int c, char* arg) static int my_parser(struct lxc_arguments* args, int c, char* arg)
{ {
switch (c) { switch (c) {
...@@ -63,6 +65,11 @@ Options :\n\ ...@@ -63,6 +65,11 @@ Options :\n\
.checker = NULL, .checker = NULL,
}; };
static int copy_config_file(const char *name, const char *file)
{
return 0;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct lxc_conf lxc_conf; struct lxc_conf lxc_conf;
...@@ -79,9 +86,22 @@ int main(int argc, char *argv[]) ...@@ -79,9 +86,22 @@ int main(int argc, char *argv[])
if (lxc_conf_init(&lxc_conf)) if (lxc_conf_init(&lxc_conf))
return -1; return -1;
if (my_args.rcfile && lxc_config_read(my_args.rcfile, &lxc_conf)) if (my_args.rcfile && lxc_config_read(my_args.rcfile, &lxc_conf)) {
ERROR("failed to read the configuration file");
return -1; return -1;
}
return lxc_create(my_args.name, &lxc_conf); if (lxc_create(my_args.name, &lxc_conf)) {
ERROR("failed to create the container");
return -1;
}
if (copy_config_file(my_args.name, my_args.rcfile)) {
ERROR("failed to copy the configuration file");
lxc_destroy(my_args.name);
return -1;
}
return 0;
} }
...@@ -67,7 +67,7 @@ int lxc_file_for_each_line(const char *file, lxc_file_cb callback, ...@@ -67,7 +67,7 @@ int lxc_file_for_each_line(const char *file, lxc_file_cb callback,
char *buffer, size_t len, void* data) char *buffer, size_t len, void* data)
{ {
FILE *f; FILE *f;
int err = -1; int err = 0;
f = fopen(file, "r"); f = fopen(file, "r");
if (!f) { if (!f) {
......
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