lxccontainer: switch api to new clearer callbacks

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2017-05-31 18:59:29 +02:00
parent 973082f566
commit 6afd673f2e
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D
3 changed files with 19 additions and 14 deletions

View File

@ -1040,7 +1040,7 @@ static int set_config_network_ipv4(const char *key, const char *value,
char *addr = NULL, *bcast = NULL, *prefix = NULL;
if (config_value_empty(value))
return lxc_clear_config_item(lxc_conf, key);
return clr_config_network_item(key, lxc_conf);
netdev = network_netdev(key, value, &lxc_conf->network);
if (!netdev)
@ -1169,7 +1169,7 @@ static int set_config_network_ipv6(const char *key, const char *value,
char *slash, *valdup, *netmask;
if (config_value_empty(value))
return lxc_clear_config_item(lxc_conf, key);
return clr_config_network_item(key, lxc_conf);
netdev = network_netdev(key, value, &lxc_conf->network);
if (!netdev)
@ -2128,7 +2128,7 @@ static int set_config_fstab(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
if (config_value_empty(value)) {
lxc_clear_config_item(lxc_conf, key);
clr_config_fstab(key, lxc_conf);
return -1;
}
@ -2452,7 +2452,7 @@ static int set_config_includefiles(const char *key, const char *value,
{
/* Set config value to default. */
if (config_value_empty(value)) {
lxc_clear_config_item(lxc_conf, key);
clr_config_includefiles(key, lxc_conf);
return 0;
}
@ -2511,7 +2511,7 @@ static int set_config_utsname(const char *key, const char *value,
struct utsname *utsname;
if (config_value_empty(value)) {
lxc_clear_config_item(lxc_conf, key);
clr_config_utsname(key, lxc_conf);
return 0;
}
@ -2771,11 +2771,6 @@ static inline int lxc_get_conf_int(struct lxc_conf *c, char *retv, int inlen,
return snprintf(retv, inlen, "%d", v);
}
int lxc_clear_config_item(struct lxc_conf *c, const char *key)
{
return 0;
}
/* Write out a configuration file. */
void write_config(FILE *fout, struct lxc_conf *c)
{

View File

@ -38,7 +38,7 @@ struct lxc_config_t {
char *name;
config_set_cb set;
config_get_cb get;
config_clr_cb clear;
config_clr_cb clr;
};
extern struct lxc_config_t *lxc_getconfig(const char *key);

View File

@ -1676,17 +1676,27 @@ static void do_clear_unexp_config_line(struct lxc_conf *conf, const char *key)
WARN("Error clearing configuration for %s", key);
}
static bool do_lxcapi_clear_config_item(struct lxc_container *c, const char *key)
static bool do_lxcapi_clear_config_item(struct lxc_container *c,
const char *key)
{
int ret;
int ret = 1;
struct lxc_config_t *config;
if (!c || !c->lxc_conf)
return false;
if (container_mem_lock(c))
return false;
ret = lxc_clear_config_item(c->lxc_conf, key);
config = lxc_getconfig(key);
/* Verify that the config key exists and that it has a callback
* implemented.
*/
if (config && config->clr)
ret = config->clr(key, c->lxc_conf);
if (!ret)
do_clear_unexp_config_line(c->lxc_conf, key);
container_mem_unlock(c);
return ret == 0;
}