[lxc-devel] [PATCH] lxc-create: conside create succeed when container is already created

Qiang Huang h.huangqiang at huawei.com
Mon Sep 16 03:37:02 UTC 2013


Sometimes we use:
lxc-create -n xxx -f config
to copy config to the default lxcpath with the rootfs already
exist.
But we will get error right now, so fix this.

Signed-off-by: Qiang Huang <h.huangqiang at huawei.com>
---
 src/lxc/lxccontainer.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 79237df..e8436cc 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -1018,9 +1018,15 @@ static bool lxcapi_create(struct lxc_container *c, const char *t,
 		goto out;
 	}

-	/* container is already created if we have a config and rootfs.path is accessible */
-	if (lxcapi_is_defined(c) && c->lxc_conf && c->lxc_conf->rootfs.path && access(c->lxc_conf->rootfs.path, F_OK) == 0)
+	/*
+	 * Container is already created if we have a config and rootfs.path
+	 * is accessible. We'll conside lxc_create succeed in this condition.
+	 */
+	if (lxcapi_is_defined(c) && c->lxc_conf && c->lxc_conf->rootfs.path &&
+		access(c->lxc_conf->rootfs.path, F_OK) == 0) {
+		bret = true;
 		goto out;
+	}

 	/* Mark that this container is being created */
 	if ((partial_fd = create_partial(c)) < 0)
-- 
1.8.3





More information about the lxc-devel mailing list