[lxc-devel] [PATCH] Create lxcpath if it's missing
S.Çağlar Onur
caglar at 10ur.org
Tue May 12 18:27:48 UTC 2015
Otherwise calling list_defined_containers just after installing LXC ends up with the following error
lxc: lxccontainer.c: list_defined_containers: 4310 No such file or directory - opendir on lxcpath
$ /home/caglar/go/src/gopkg.in/lxc/go-lxc.v2/examples/list
2015/05/12 14:23:08 Defined containers:
lxc: lxccontainer.c: list_defined_containers: 4310 No such file or directory - opendir on lxcpath
2015/05/12 14:23:08
2015/05/12 14:23:08 Active containers:
2015/05/12 14:23:08
2015/05/12 14:23:08 Active and Defined containers:
$
Signed-off-by: S.Çağlar Onur <caglar at 10ur.org>
---
src/lxc/lxccontainer.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 8999f44..e8bade3 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -3965,6 +3965,11 @@ int list_defined_containers(const char *lxcpath, char ***names, struct lxc_conta
if (!lxcpath)
lxcpath = lxc_global_config_value("lxc.lxcpath");
+ if (mkdir_p(lxcpath, 0755) < 0) {
+ SYSERROR("failed to create lxcpath directory %s", lxcpath);
+ return -1;
+ }
+
dir = opendir(lxcpath);
if (!dir) {
SYSERROR("opendir on lxcpath");
--
2.1.4
More information about the lxc-devel
mailing list