On 03/31/2013 04:22 PM, S.Çağlar Onur wrote:
> From: "S.Çağlar Onur" <cag...@10ur.org>
> 
> 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.
> 
>>> c = lxc.Container("r")
>>>> c.create("ubuntu")
> True
>>>> c.create("ubuntu")
> True
>>>> c.create("ubuntu")
> True
>>>> c.create("ubuntu")
> True
>>>> c.create("ubuntu")
>>>> c.destroy()
> True
>>>> c.destroy()
> lxc-destroy: 'r' does not exist
> False
>>>> c.destroy()
> lxc-destroy: 'r' does not exist
> False
> 
> New behaviour
> 
>>>> c = lxc.Container("r")
>>>> c.create('ubuntu')
> True
>>>> c.create('ubuntu')
> False
>>>> c.destroy()
> True
>>>> c.destroy()
> False
>>>>


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

I personally always considered ".create()" to mean "generate a new
rootfs" which doesn't at all mean "generate a new config file".

".destroy()" on the other hand destroys everything, including the config.



> Signed-off-by: S.Çağlar Onur <cag...@10ur.org>
> ---
>  src/lxc/lxccontainer.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
> index 480c4f5..7a11c85 100644
> --- a/src/lxc/lxccontainer.c
> +++ b/src/lxc/lxccontainer.c
> @@ -508,7 +508,7 @@ static bool lxcapi_create(struct lxc_container *c, char 
> *t, char *const argv[])
>       int len, nargs = 0;
>       char **newargv;
>  
> -     if (!c)
> +     if (!c || lxcapi_is_defined(c))
>               return false;
>  
>       len = strlen(LXCTEMPLATEDIR) + strlen(t) + strlen("/lxc-") + 1;
> @@ -785,7 +785,7 @@ static bool lxcapi_destroy(struct lxc_container *c)
>       pid_t pid;
>       int ret, status;
>  
> -     if (!c)
> +     if (!c || !lxcapi_is_defined(c))
>               return false;
>  
>       pid = fork();
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete 
for recognition, cash, and the chance to get your game on Steam. 
$5K grand prize plus 10 genre and skill prizes. Submit your demo 
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel

Reply via email to