Commit 469711c5 by 2xsec

tools: lxc-info: share internal API symbols

Signed-off-by: 's avatar2xsec <dh48.jeong@samsung.com>
parent b14fc100
...@@ -274,7 +274,7 @@ lxc_destroy_SOURCES = tools/lxc_destroy.c tools/arguments.c tools/tool_utils.c ...@@ -274,7 +274,7 @@ lxc_destroy_SOURCES = tools/lxc_destroy.c tools/arguments.c tools/tool_utils.c
lxc_device_SOURCES = tools/lxc_device.c tools/arguments.c tools/tool_utils.c lxc_device_SOURCES = tools/lxc_device.c tools/arguments.c tools/tool_utils.c
lxc_execute_SOURCES = tools/lxc_execute.c tools/arguments.c tools/tool_utils.c lxc_execute_SOURCES = tools/lxc_execute.c tools/arguments.c tools/tool_utils.c
lxc_freeze_SOURCES = tools/lxc_freeze.c tools/arguments.c lxc_freeze_SOURCES = tools/lxc_freeze.c tools/arguments.c
lxc_info_SOURCES = tools/lxc_info.c tools/arguments.c tools/tool_utils.c lxc_info_SOURCES = tools/lxc_info.c tools/arguments.c
lxc_monitor_SOURCES = tools/lxc_monitor.c tools/arguments.c tools/tool_utils.c lxc_monitor_SOURCES = tools/lxc_monitor.c tools/arguments.c tools/tool_utils.c
lxc_ls_SOURCES = tools/lxc_ls.c tools/arguments.c tools/tool_utils.c lxc_ls_SOURCES = tools/lxc_ls.c tools/arguments.c tools/tool_utils.c
lxc_copy_SOURCES = tools/lxc_copy.c tools/arguments.c tools/tool_utils.c lxc_copy_SOURCES = tools/lxc_copy.c tools/arguments.c tools/tool_utils.c
......
...@@ -34,7 +34,10 @@ ...@@ -34,7 +34,10 @@
#include <lxc/lxccontainer.h> #include <lxc/lxccontainer.h>
#include "arguments.h" #include "arguments.h"
#include "tool_utils.h" #include "log.h"
#include "utils.h"
lxc_log_define(lxc_info, lxc);
static bool ips; static bool ips;
static bool state; static bool state;
...@@ -45,14 +48,16 @@ static char **key = NULL; ...@@ -45,14 +48,16 @@ static char **key = NULL;
static int keys = 0; static int keys = 0;
static int filter_count = 0; static int filter_count = 0;
static int my_parser(struct lxc_arguments* args, int c, char* arg) static int my_parser(struct lxc_arguments *args, int c, char *arg)
{ {
char **newk; char **newk;
switch (c) { switch (c) {
case 'c': case 'c':
newk = realloc(key, (keys + 1) * sizeof(key[0])); newk = realloc(key, (keys + 1) * sizeof(key[0]));
if (!newk) if (!newk)
return -1; return -1;
key = newk; key = newk;
key[keys] = arg; key[keys] = arg;
keys++; keys++;
...@@ -153,6 +158,7 @@ static void print_net_stats(struct lxc_container *c) ...@@ -153,6 +158,7 @@ static void print_net_stats(struct lxc_container *c)
for(netnr = 0; ;netnr++) { for(netnr = 0; ;netnr++) {
sprintf(buf, "lxc.net.%d.type", netnr); sprintf(buf, "lxc.net.%d.type", netnr);
type = c->get_running_config_item(c, buf); type = c->get_running_config_item(c, buf);
if (!type) if (!type)
break; break;
...@@ -163,9 +169,11 @@ static void print_net_stats(struct lxc_container *c) ...@@ -163,9 +169,11 @@ static void print_net_stats(struct lxc_container *c)
sprintf(buf, "lxc.net.%d.link", netnr); sprintf(buf, "lxc.net.%d.link", netnr);
} }
free(type); free(type);
ifname = c->get_running_config_item(c, buf); ifname = c->get_running_config_item(c, buf);
if (!ifname) if (!ifname)
return; return;
printf("%-15s %s\n", "Link:", ifname); printf("%-15s %s\n", "Link:", ifname);
fflush(stdout); fflush(stdout);
...@@ -303,11 +311,13 @@ static int print_info(const char *name, const char *lxcpath) ...@@ -303,11 +311,13 @@ static int print_info(const char *name, const char *lxcpath)
if (my_args.rcfile) { if (my_args.rcfile) {
c->clear_config(c); c->clear_config(c);
if (!c->load_config(c, my_args.rcfile)) { if (!c->load_config(c, my_args.rcfile)) {
fprintf(stderr, "Failed to load rcfile\n"); fprintf(stderr, "Failed to load rcfile\n");
lxc_container_put(c); lxc_container_put(c);
return -1; return -1;
} }
c->configfile = strdup(my_args.rcfile); c->configfile = strdup(my_args.rcfile);
if (!c->configfile) { if (!c->configfile) {
fprintf(stderr, "Out of memory setting new config filename\n"); fprintf(stderr, "Out of memory setting new config filename\n");
...@@ -333,9 +343,8 @@ static int print_info(const char *name, const char *lxcpath) ...@@ -333,9 +343,8 @@ static int print_info(const char *name, const char *lxcpath)
print_info_msg_str("Name:", c->name); print_info_msg_str("Name:", c->name);
} }
if (state) { if (state)
print_info_msg_str("State:", c->state(c)); print_info_msg_str("State:", c->state(c));
}
if (c->is_running(c)) { if (c->is_running(c)) {
if (pid) { if (pid) {
...@@ -348,10 +357,12 @@ static int print_info(const char *name, const char *lxcpath) ...@@ -348,10 +357,12 @@ static int print_info(const char *name, const char *lxcpath)
if (ips) { if (ips) {
fflush(stdout); fflush(stdout);
char **addresses = c->get_ips(c, NULL, NULL, 0); char **addresses = c->get_ips(c, NULL, NULL, 0);
if (addresses) { if (addresses) {
char *address; char *address;
i = 0; i = 0;
while (addresses[i]) { while (addresses[i]) {
address = addresses[i]; address = addresses[i];
print_info_msg_str("IP:", address); print_info_msg_str("IP:", address);
...@@ -380,6 +391,7 @@ static int print_info(const char *name, const char *lxcpath) ...@@ -380,6 +391,7 @@ static int print_info(const char *name, const char *lxcpath)
else else
printf("%s = %s\n", key[i], val); printf("%s = %s\n", key[i], val);
} }
free(val); free(val);
} else if (len == 0) { } else if (len == 0) {
if (!humanize && keys == 1) if (!humanize && keys == 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