On Mon, Sep 16, 2013 at 11:37:02AM +0800, Qiang Huang wrote: > 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.
Hmm, I'm not sure I understand. Running "lxc-create -n xxx -f config" when xxx already exists is an error and should return an error code so the current code seems perfectly right to me. The API should only return true if the requested action has been carried out, in this case, creating a container xxx with config as its config file. If the container already exists, it can't do that and so should return false. > > Signed-off-by: Qiang Huang <h.huangqi...@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 > -- Stéphane Graber Ubuntu developer http://www.ubuntu.com
signature.asc
Description: Digital signature
------------------------------------------------------------------------------ LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99! 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
_______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel