[lxc-devel] [PATCH] destroy the original container after making sure the snapshot exists (fixes #224)

S.Çağlar Onur caglar at 10ur.org
Sun May 25 02:19:03 UTC 2014


On Sat, May 24, 2014 at 6:18 PM, Serge Hallyn <serge.hallyn at ubuntu.com> wrote:
> Quoting S.Çağlar Onur (caglar at 10ur.org):
>
> Hi,
>
> could you please add a Signed-off-by when you resend?
>
>> ---
>>  src/lxc/lxccontainer.c | 16 +++++++++-------
>>  1 file changed, 9 insertions(+), 7 deletions(-)
>>
>> diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
>> index fdac433..029daf7 100644
>> --- a/src/lxc/lxccontainer.c
>> +++ b/src/lxc/lxccontainer.c
>> @@ -3083,13 +3083,7 @@ static bool lxcapi_snapshot_restore(struct lxc_container *c, const char *snapnam
>>
>>       if (!newname)
>>               newname = c->name;
>> -     if (strcmp(c->name, newname) == 0) {
>> -             if (!lxcapi_destroy(c)) {
>> -                     ERROR("Could not destroy existing container %s", newname);
>> -                     bdev_put(bdev);
>> -                     return false;
>> -             }
>> -     }
>> +
>>       ret = snprintf(clonelxcpath, MAXPATHLEN, "%ssnaps/%s", c->config_path, c->name);
>>       if (ret < 0 || ret >= MAXPATHLEN) {
>>               bdev_put(bdev);
>> @@ -3105,6 +3099,14 @@ static bool lxcapi_snapshot_restore(struct lxc_container *c, const char *snapnam
>>               return false;
>>       }
>>
>> +     if (strcmp(c->name, newname) == 0) {
>> +             if (!lxcapi_destroy(c)) {
>
> Makes sense, except you do also need to lxc_container_put(snap) here.

Yep, new one coming in a minute...

>> +                     ERROR("Could not destroy existing container %s", newname);
>> +                     bdev_put(bdev);
>> +                     return false;
>> +             }
>> +     }
>> +
>>       if (strcmp(bdev->type, "dir") != 0 && strcmp(bdev->type, "loop") != 0)
>>               flags = LXC_CLONE_SNAPSHOT | LXC_CLONE_MAYBE_SNAPSHOT;
>>       rest = lxcapi_clone(snap, newname, c->config_path, flags,
>> --
>> 1.9.1
>>
>> _______________________________________________
>> lxc-devel mailing list
>> lxc-devel at lists.linuxcontainers.org
>> http://lists.linuxcontainers.org/listinfo/lxc-devel
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel



-- 
S.Çağlar Onur <caglar at 10ur.org>


More information about the lxc-devel mailing list