]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
report error in lxc_get_lock
authorMichel Normand <normand@fr.ibm.com>
Sun, 17 May 2009 11:43:51 +0000 (13:43 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Sun, 17 May 2009 11:43:51 +0000 (13:43 +0200)
report error in lxc_get_lock and remove the call to lxc_strerror
that become useless for these errors.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/lock.c
src/lxc/lxc_execute.c
src/lxc/lxc_start.c

index 656850ba26a87fee4a6542746151b9e0e210bcf3..76eaccf7444575e7c9f57dc8d7f37ab43825b6e4 100644 (file)
@@ -70,23 +70,24 @@ int lxc_get_lock(const char *name)
        ret = __lxc_get_lock(name);
        if (ret < 0)
                goto out_err;
-out:
+
        return ret;
 out_err:
        switch (-ret) {
        case EWOULDBLOCK:
-               ret = -LXC_ERROR_EBUSY;
-               goto out;
+               ERROR("container '%s' is busy", name);
+               break;
        case ENOENT:
-               ret = -LXC_ERROR_ENOENT;
-               goto out;
+               ERROR("container '%s' is not found", name);
+               break;
        case EACCES:
-               ret = -LXC_ERROR_EACCES;
-               goto out;
+               ERROR("not enough privilege to use container '%s'", name);
+               break;
        default:
-               ret = -LXC_ERROR_LOCK;
-               goto out;
+               ERROR("container '%s' failed to lock : %s",
+                     name, strerror(-ret));
        }
+       return -1;
 }
 
 int lxc_check_lock(const char *name)
index 27aee6b4797a956ecc2841cd07711fae1ff010ad..0c0f3a9b2a675eac5020bb4ce8789c3b23cb3c9a 100644 (file)
@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
        /* lxc-init --mount-procfs -- .... */
        args = malloc((argc + 3)*sizeof(*args));
        if (!args) {
-               ERROR("failed to allocate memory for '%s'\n", name);
+               ERROR("failed to allocate memory for '%s'", name);
                goto out;
        }
 
@@ -114,8 +114,7 @@ int main(int argc, char *argv[])
 
        ret = lxc_start(name, args);
        if (ret) {
-               ERROR("failed to start '%s': %s\n", name,
-                     lxc_strerror(ret));
+               ERROR("failed to start '%s'", name);
                goto out;
        }
 
@@ -123,8 +122,7 @@ int main(int argc, char *argv[])
 out:
        if (autodestroy) {
                if (lxc_destroy(name)) {
-                       ERROR("failed to destroy '%s': %s\n",
-                             name, lxc_strerror(ret));
+                       ERROR("failed to destroy '%s'", name);
                        ret = 1;
                }
        }
index a60d1491d791c73e76581378451527857fa72f26..809041e9270565ad567818ed5d295d55af7f0518 100644 (file)
@@ -98,7 +98,7 @@ int main(int argc, char *argv[])
 
        err = lxc_start(name, args);
        if (err) {
-               ERROR("failed to start : %s\n", lxc_strerror(err));
+               ERROR("failed to start '%s'", name);
                err = 1;
        }