From 3f903c04fea9e59c2057defd8e906d20199b7203 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Fri, 9 Jun 2017 17:20:20 +0200 Subject: [PATCH] commands: add TRACE()ers Signed-off-by: Christian Brauner --- src/lxc/commands.c | 28 +++++++++++++++++++++------- src/lxc/start.c | 1 + 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/lxc/commands.c b/src/lxc/commands.c index bb354a505..d9f955fc0 100644 --- a/src/lxc/commands.c +++ b/src/lxc/commands.c @@ -297,12 +297,20 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped, return -1; sock = lxc_abstract_unix_connect(path); + TRACE("command %s tries to connect to \"@%s\"", + lxc_cmd_str(cmd->req.cmd), offset); if (sock < 0) { - if (errno == ECONNREFUSED) + if (errno == ECONNREFUSED) { + TRACE("command %s failed to connect to \"@%s\": %s", + lxc_cmd_str(cmd->req.cmd), offset, + strerror(errno)); *stopped = 1; - else - SYSERROR("Command %s failed to connect to \"@%s\".", - lxc_cmd_str(cmd->req.cmd), offset); + } else { + SYSERROR("command %s failed to connect to \"@%s\": %s", + lxc_cmd_str(cmd->req.cmd), offset, + strerror(errno)); + } + return -1; } @@ -462,20 +470,26 @@ char *lxc_cmd_get_cgroup_path(const char *name, const char *lxcpath, }; ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL); - if (ret < 0) + if (ret < 0) { + TRACE("command %s failed for container \"%s\": %s.", + lxc_cmd_str(cmd.req.cmd), name, strerror(errno)); return NULL; + } if (!ret) { - WARN("Container \"%s\" has stopped before sending its state.", name); + WARN("container \"%s\" has stopped before sending its state", name); return NULL; } if (cmd.rsp.ret < 0 || cmd.rsp.datalen < 0) { - ERROR("Command %s failed for container \"%s\": %s.", + ERROR("command %s failed for container \"%s\": %s", lxc_cmd_str(cmd.req.cmd), name, strerror(-cmd.rsp.ret)); return NULL; } + TRACE("command %s successful for container \"%s\"", + lxc_cmd_str(cmd.req.cmd), name); + return cmd.rsp.data; } diff --git a/src/lxc/start.c b/src/lxc/start.c index fbc196692..0d1bdb5cc 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -384,6 +384,7 @@ int lxc_poll(const char *name, struct lxc_handler *handler) DEBUG("Not starting utmp handler as CAP_SYS_BOOT cannot be dropped without capabilities support."); #endif } + TRACE("lxc mainloop is ready"); return lxc_mainloop(&descr, -1); -- 2.47.3