]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tools: lxc-cgroup: share internal API symbols
author2xsec <dh48.jeong@samsung.com>
Thu, 28 Jun 2018 14:13:01 +0000 (23:13 +0900)
committer2xsec <dh48.jeong@samsung.com>
Thu, 28 Jun 2018 14:13:01 +0000 (23:13 +0900)
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
src/lxc/Makefile.am
src/lxc/tools/lxc_cgroup.c

index 81c0d17ba49d25b18734256e7f9fdc22a5a747f1..f4a76fdb74e6e8ff2b1c7f684f3f7835f3a1fab4 100644 (file)
@@ -267,7 +267,7 @@ LDADD=liblxc.la @CAP_LIBS@ @GNUTLS_LIBS@ @SELINUX_LIBS@ @SECCOMP_LIBS@
 if ENABLE_TOOLS
 lxc_attach_SOURCES = tools/lxc_attach.c tools/arguments.c tools/tool_utils.c
 lxc_autostart_SOURCES = tools/lxc_autostart.c tools/arguments.c tools/tool_utils.c
-lxc_cgroup_SOURCES = tools/lxc_cgroup.c tools/arguments.c tools/tool_utils.c
+lxc_cgroup_SOURCES = tools/lxc_cgroup.c tools/arguments.c
 lxc_config_SOURCES = tools/lxc_config.c tools/arguments.c tools/tool_utils.c
 lxc_console_SOURCES = tools/lxc_console.c tools/arguments.c tools/tool_utils.c
 lxc_destroy_SOURCES = tools/lxc_destroy.c tools/arguments.c tools/tool_utils.c
index 16a10a11aa4dbac36d263d0512886f07d1cd718d..06706c84e82eb036de711ee7e97fbbed73f22d40 100644 (file)
 #include <lxc/lxccontainer.h>
 
 #include "arguments.h"
-#include "tool_utils.h"
+#include "log.h"
+
+lxc_log_define(lxc_cgroup, lxc);
 
 static int my_checker(const struct lxc_arguments* args)
 {
        if (!args->argc) {
-               lxc_error(args, "Missing state object");
+               ERROR("Missing state object");
                return -1;
        }
 
@@ -94,28 +96,29 @@ int main(int argc, char *argv[])
 
        if (my_args.rcfile) {
                c->clear_config(c);
+
                if (!c->load_config(c, my_args.rcfile)) {
-                       lxc_error(&my_args, "Failed to load rcfile");
+                       ERROR("Failed to load rcfile");
                        lxc_container_put(c);
                        exit(EXIT_FAILURE);
                }
 
                c->configfile = strdup(my_args.rcfile);
                if (!c->configfile) {
-                       lxc_error(&my_args, "Out of memory setting new config filename");
+                       ERROR("Out of memory setting new config filename");
                        lxc_container_put(c);
                        exit(EXIT_FAILURE);
                }
        }
 
        if (!c->may_control(c)) {
-               lxc_error(&my_args, "Insufficent privileges to control %s:%s", my_args.lxcpath[0], my_args.name);
+               ERROR("Insufficent privileges to control %s:%s", my_args.lxcpath[0], my_args.name);
                lxc_container_put(c);
                exit(EXIT_FAILURE);
        }
 
        if (!c->is_running(c)) {
-               lxc_error(&my_args, "'%s:%s' is not running", my_args.lxcpath[0], my_args.name);
+               ERROR("'%s:%s' is not running", my_args.lxcpath[0], my_args.name);
                lxc_container_put(c);
                exit(EXIT_FAILURE);
        }
@@ -124,25 +127,26 @@ int main(int argc, char *argv[])
                value = my_args.argv[1];
 
                if (!c->set_cgroup_item(c, state_object, value)) {
-                       lxc_error(&my_args, "Failed to assign '%s' value to '%s' for '%s'",
-                                 value, state_object, my_args.name);
+                       ERROR("Failed to assign '%s' value to '%s' for '%s'",
+                             value, state_object, my_args.name);
                        lxc_container_put(c);
                        exit(EXIT_FAILURE);
                }
        } else {
-               char buffer[TOOL_MAXPATHLEN];
+               char buffer[MAXPATHLEN];
                int ret;
 
-               ret = c->get_cgroup_item(c, state_object, buffer, TOOL_MAXPATHLEN);
+               ret = c->get_cgroup_item(c, state_object, buffer, MAXPATHLEN);
                if (ret < 0) {
-                       lxc_error(&my_args, "Failed to retrieve value of '%s' for '%s:%s'",
-                                 state_object, my_args.lxcpath[0], my_args.name);
+                       ERROR("Failed to retrieve value of '%s' for '%s:%s'",
+                             state_object, my_args.lxcpath[0], my_args.name);
                        lxc_container_put(c);
                        exit(EXIT_FAILURE);
                }
-               printf("%*s", ret, buffer);
+               INFO("%*s", ret, buffer);
        }
 
        lxc_container_put(c);
+
        exit(EXIT_SUCCESS);
 }