Commit 4c200d12 by Michel Normand Committed by Daniel Lezcano

report error in lxc_get_lock

report error in lxc_get_lock and remove the call to lxc_strerror that become useless for these errors. Signed-off-by: 's avatarMichel Normand <normand@fr.ibm.com> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 305dbab7
...@@ -70,23 +70,24 @@ int lxc_get_lock(const char *name) ...@@ -70,23 +70,24 @@ int lxc_get_lock(const char *name)
ret = __lxc_get_lock(name); ret = __lxc_get_lock(name);
if (ret < 0) if (ret < 0)
goto out_err; goto out_err;
out:
return ret; return ret;
out_err: out_err:
switch (-ret) { switch (-ret) {
case EWOULDBLOCK: case EWOULDBLOCK:
ret = -LXC_ERROR_EBUSY; ERROR("container '%s' is busy", name);
goto out; break;
case ENOENT: case ENOENT:
ret = -LXC_ERROR_ENOENT; ERROR("container '%s' is not found", name);
goto out; break;
case EACCES: case EACCES:
ret = -LXC_ERROR_EACCES; ERROR("not enough privilege to use container '%s'", name);
goto out; break;
default: default:
ret = -LXC_ERROR_LOCK; ERROR("container '%s' failed to lock : %s",
goto out; name, strerror(-ret));
} }
return -1;
} }
int lxc_check_lock(const char *name) int lxc_check_lock(const char *name)
......
...@@ -100,7 +100,7 @@ int main(int argc, char *argv[]) ...@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
/* lxc-init --mount-procfs -- .... */ /* lxc-init --mount-procfs -- .... */
args = malloc((argc + 3)*sizeof(*args)); args = malloc((argc + 3)*sizeof(*args));
if (!args) { if (!args) {
ERROR("failed to allocate memory for '%s'\n", name); ERROR("failed to allocate memory for '%s'", name);
goto out; goto out;
} }
...@@ -114,8 +114,7 @@ int main(int argc, char *argv[]) ...@@ -114,8 +114,7 @@ int main(int argc, char *argv[])
ret = lxc_start(name, args); ret = lxc_start(name, args);
if (ret) { if (ret) {
ERROR("failed to start '%s': %s\n", name, ERROR("failed to start '%s'", name);
lxc_strerror(ret));
goto out; goto out;
} }
...@@ -123,8 +122,7 @@ int main(int argc, char *argv[]) ...@@ -123,8 +122,7 @@ int main(int argc, char *argv[])
out: out:
if (autodestroy) { if (autodestroy) {
if (lxc_destroy(name)) { if (lxc_destroy(name)) {
ERROR("failed to destroy '%s': %s\n", ERROR("failed to destroy '%s'", name);
name, lxc_strerror(ret));
ret = 1; ret = 1;
} }
} }
......
...@@ -98,7 +98,7 @@ int main(int argc, char *argv[]) ...@@ -98,7 +98,7 @@ int main(int argc, char *argv[])
err = lxc_start(name, args); err = lxc_start(name, args);
if (err) { if (err) {
ERROR("failed to start : %s\n", lxc_strerror(err)); ERROR("failed to start '%s'", name);
err = 1; err = 1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment