Commit 0c9a9339 by Stéphane Graber Committed by GitHub

Merge pull request #1746 from brauner/2017-08-10/further_lxc_2.1_preparations

further lxc 2.1 preparations
parents 065055b6 7451daf8
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
* *
* Authors: * Authors:
* Daniel Lezcano <daniel.lezcano at free.fr> * Daniel Lezcano <daniel.lezcano at free.fr>
* Serge Hallyn <serge@hallyn.com>
* Christian Brauner <christian.brauner@ubuntu.com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -31,11 +33,13 @@ ...@@ -31,11 +33,13 @@
struct lxc_conf; struct lxc_conf;
struct lxc_list; struct lxc_list;
typedef int (*config_set_cb)(const char *, const char *, struct lxc_conf *, typedef int (*config_set_cb)(const char *key, const char *value,
struct lxc_conf *conf, void *data);
typedef int (*config_get_cb)(const char *key, char *value, int inlen,
struct lxc_conf *conf, void *data);
typedef int (*config_clr_cb)(const char *key, struct lxc_conf *conf,
void *data); void *data);
typedef int (*config_get_cb)(const char *, char *, int, struct lxc_conf *,
void *);
typedef int (*config_clr_cb)(const char *, struct lxc_conf *c, void *data);
struct lxc_config_t { struct lxc_config_t {
char *name; char *name;
config_set_cb set; config_set_cb set;
...@@ -44,8 +48,14 @@ struct lxc_config_t { ...@@ -44,8 +48,14 @@ struct lxc_config_t {
}; };
extern struct lxc_config_t *lxc_getconfig(const char *key); extern struct lxc_config_t *lxc_getconfig(const char *key);
extern int lxc_list_nicconfigs(struct lxc_conf *c, const char *key, char *retv, int inlen);
extern int lxc_listconfigs(char *retv, int inlen); /* List all configuration items associated with a given network. For example
* pass "lxc.net.[i]" to retrieve all configuration items associated with
* the network associated with index [i].
*/
extern int lxc_list_net(struct lxc_conf *c, const char *key, char *retv,
int inlen);
extern int lxc_list_config_items(char *retv, int inlen);
extern int lxc_config_read(const char *file, struct lxc_conf *conf, bool from_include); extern int lxc_config_read(const char *file, struct lxc_conf *conf, bool from_include);
extern int append_unexp_config_line(const char *line, struct lxc_conf *conf); extern int append_unexp_config_line(const char *line, struct lxc_conf *conf);
......
...@@ -680,4 +680,3 @@ bool parse_limit_value(const char **value, unsigned long *res) ...@@ -680,4 +680,3 @@ bool parse_limit_value(const char **value, unsigned long *res)
return true; return true;
} }
...@@ -2249,7 +2249,7 @@ WRAP_API_1(char *, lxcapi_get_running_config_item, const char *) ...@@ -2249,7 +2249,7 @@ WRAP_API_1(char *, lxcapi_get_running_config_item, const char *)
static int do_lxcapi_get_keys(struct lxc_container *c, const char *key, char *retv, int inlen) static int do_lxcapi_get_keys(struct lxc_container *c, const char *key, char *retv, int inlen)
{ {
if (!key) if (!key)
return lxc_listconfigs(retv, inlen); return lxc_list_config_items(retv, inlen);
/* /*
* Support 'lxc.net.<idx>', i.e. 'lxc.net.0' * Support 'lxc.net.<idx>', i.e. 'lxc.net.0'
* This is an intelligent result to show which keys are valid given * This is an intelligent result to show which keys are valid given
...@@ -2260,8 +2260,8 @@ static int do_lxcapi_get_keys(struct lxc_container *c, const char *key, char *re ...@@ -2260,8 +2260,8 @@ static int do_lxcapi_get_keys(struct lxc_container *c, const char *key, char *re
if (container_mem_lock(c)) if (container_mem_lock(c))
return -1; return -1;
int ret = -1; int ret = -1;
if (strncmp(key, "lxc.net.", 8) == 0) if (!strncmp(key, "lxc.net.", 8))
ret = lxc_list_nicconfigs(c->lxc_conf, key, retv, inlen); ret = lxc_list_net(c->lxc_conf, key, retv, inlen);
else if (strncmp(key, "lxc.network.", 12) == 0) else if (strncmp(key, "lxc.network.", 12) == 0)
ret = lxc_list_nicconfigs_legacy(c->lxc_conf, key, retv, inlen); ret = lxc_list_nicconfigs_legacy(c->lxc_conf, key, retv, inlen);
container_mem_unlock(c); container_mem_unlock(c);
......
...@@ -445,6 +445,7 @@ bool is_valid_storage_type(const char *type) ...@@ -445,6 +445,7 @@ bool is_valid_storage_type(const char *type)
strcmp(type, "loop") == 0 || strcmp(type, "loop") == 0 ||
strcmp(type, "lvm") == 0 || strcmp(type, "lvm") == 0 ||
strcmp(type, "nbd") == 0 || strcmp(type, "nbd") == 0 ||
strcmp(type, "overlay") == 0 ||
strcmp(type, "overlayfs") == 0 || strcmp(type, "overlayfs") == 0 ||
strcmp(type, "rbd") == 0 || strcmp(type, "rbd") == 0 ||
strcmp(type, "zfs") == 0) strcmp(type, "zfs") == 0)
......
...@@ -38,7 +38,7 @@ int main(int argc, char *argv[]) ...@@ -38,7 +38,7 @@ int main(int argc, char *argv[])
int fulllen = 0, inlen = 0, ret = EXIT_FAILURE; int fulllen = 0, inlen = 0, ret = EXIT_FAILURE;
char *key, *keys, *saveptr = NULL; char *key, *keys, *saveptr = NULL;
fulllen = lxc_listconfigs(NULL, inlen); fulllen = lxc_list_config_items(NULL, inlen);
keys = malloc(sizeof(char) * fulllen + 1); keys = malloc(sizeof(char) * fulllen + 1);
if (!keys) { if (!keys) {
...@@ -46,7 +46,7 @@ int main(int argc, char *argv[]) ...@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
exit(ret); exit(ret);
} }
if (lxc_listconfigs(keys, fulllen) != fulllen) { if (lxc_list_config_items(keys, fulllen) != fulllen) {
lxc_error("%s\n", "failed to retrieve configuration keys"); lxc_error("%s\n", "failed to retrieve configuration keys");
goto on_error; goto on_error;
} }
......
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