<div dir="ltr">Hi Stéphane,<br><br>Hmm, then I believe there is another bug somewhere cause here is what happens with your ordering;<div><br><div><div>caglar@qgq:~/Project/lxc$ sudo python3</div><div>Python 3.2.3 (default, Oct 19 2012, 19:53:16) </div>

<div>[GCC 4.7.2] on linux2</div><div>Type "help", "copyright", "credits" or "license" for more information.</div><div>>>> import lxc</div><div>__main__:1: Warning: The python-lxc API isn't yet stable and may change at any point in the future.</div>

<div>>>> c = lxc.Container("abcdef")</div><div>>>> c.set_config_item("lxc.utsname", "blah")</div><div>True</div><div>>>> c.set_config_item("lxc.utsname", "abcdef")</div>

<div>True</div><div>>>> c.save_config()</div><div>False</div><div><div>>>> c.config_file_name</div><div>'/var/lib/lxc/abcdef/config'</div></div><div><br></div><div style>so it looks like save_config don't work if the container directory is not there and as long as I see only create calls create_container_dir to do that. </div>

<div style><br></div><div style>Maybe correct way to handle that is to call create_container_dir from save_config as well but checking the rootfs directory's existence from create/destrory?</div><div><br></div><div style>

Best,</div><br><br>On Sun, Mar 31, 2013 at 5:22 PM, Stéphane Graber <<a href="mailto:stgraber@ubuntu.com">stgraber@ubuntu.com</a>> wrote:<br>><br>> On 03/31/2013 04:22 PM, S.Çağlar Onur wrote:<br>> > From: "S.Çağlar Onur" <<a href="mailto:caglar@10ur.org">caglar@10ur.org</a>><br>

> ><br>> > Currently it behaves like following which might be confusing for the code that checks the return value of those calls to determine whether operation completed successfully or not.<br>> ><br>> >>> c = lxc.Container("r")<br>

> >>>> c.create("ubuntu")<br>> > True<br>> >>>> c.create("ubuntu")<br>> > True<br>> >>>> c.create("ubuntu")<br>> > True<br>> >>>> c.create("ubuntu")<br>

> > True<br>> >>>> c.create("ubuntu")<br>> >>>> c.destroy()<br>> > True<br>> >>>> c.destroy()<br>> > lxc-destroy: 'r' does not exist<br>> > False<br>

> >>>> c.destroy()<br>> > lxc-destroy: 'r' does not exist<br>> > False<br>> ><br>> > New behaviour<br>> ><br>> >>>> c = lxc.Container("r")<br>
> >>>> c.create('ubuntu')<br>
> > True<br>> >>>> c.create('ubuntu')<br>> > False<br>> >>>> c.destroy()<br>> > True<br>> >>>> c.destroy()<br>> > False<br>> >>>><br>

><br>><br>> Won't this break the following?<br>> c = lxc.Container("abcdef")<br>> c.set_config_item("lxc.utsname", "blah")<br>> c.save_config()<br>> c.create("ubuntu")<br>

><br>> I personally always considered ".create()" to mean "generate a new<br>> rootfs" which doesn't at all mean "generate a new config file".<br>><br>> ".destroy()" on the other hand destroys everything, including the config.<br>

><br>><br>><br>> > Signed-off-by: S.Çağlar Onur <<a href="mailto:caglar@10ur.org">caglar@10ur.org</a>><br>> > ---<br>> >  src/lxc/lxccontainer.c |    4 ++--<br>> >  1 file changed, 2 insertions(+), 2 deletions(-)<br>

> ><br>> > diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c<br>> > index 480c4f5..7a11c85 100644<br>> > --- a/src/lxc/lxccontainer.c<br>> > +++ b/src/lxc/lxccontainer.c<br>> > @@ -508,7 +508,7 @@ static bool lxcapi_create(struct lxc_container *c, char *t, char *const argv[])<br>

> >       int len, nargs = 0;<br>> >       char **newargv;<br>> ><br>> > -     if (!c)<br>> > +     if (!c || lxcapi_is_defined(c))<br>> >               return false;<br>> ><br>> >       len = strlen(LXCTEMPLATEDIR) + strlen(t) + strlen("/lxc-") + 1;<br>

> > @@ -785,7 +785,7 @@ static bool lxcapi_destroy(struct lxc_container *c)<br>> >       pid_t pid;<br>> >       int ret, status;<br>> ><br>> > -     if (!c)<br>> > +     if (!c || !lxcapi_is_defined(c))<br>

> >               return false;<br>> ><br>> >       pid = fork();<br>> ><br>><br>><br>> --<br>> Stéphane Graber<br>> Ubuntu developer<br>> <a href="http://www.ubuntu.com">http://www.ubuntu.com</a><br>

><br>><br>> ------------------------------------------------------------------------------<br>> Own the Future-Intel(R) Level Up Game Demo Contest 2013<br>> Rise to greatness in Intel's independent game demo contest. Compete<br>

> for recognition, cash, and the chance to get your game on Steam.<br>> $5K grand prize plus 10 genre and skill prizes. Submit your demo<br>> by 6/6/13. <a href="http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2">http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2</a><br>

> _______________________________________________<br>> Lxc-devel mailing list<br>> <a href="mailto:Lxc-devel@lists.sourceforge.net">Lxc-devel@lists.sourceforge.net</a><br>> <a href="https://lists.sourceforge.net/lists/listinfo/lxc-devel">https://lists.sourceforge.net/lists/listinfo/lxc-devel</a><br>

><br><br><br><br>--<br>S.Çağlar Onur <<a href="mailto:caglar@10ur.org">caglar@10ur.org</a>><br></div></div></div>