Commit 4df7f012 by Serge Hallyn

lxc-start: if we pass in a config file, then don't use any loaded config

To do this, add a c->clear_config() helper to the api. (this fixes the bug https://bugs.launchpad.net/bugs/1251352) Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 41f68357
......@@ -187,6 +187,7 @@ int main(int argc, char *argv[])
ERROR("Failed to create lxc_container");
return err;
}
c->clear_config(c);
if (!c->load_config(c, rcfile)) {
ERROR("Failed to load rcfile");
lxc_container_put(c);
......
......@@ -1151,6 +1151,14 @@ out_error:
return true;
}
static void lxcapi_clear_config(struct lxc_container *c)
{
if (c && c->lxc_conf) {
lxc_conf_free(c->lxc_conf);
c->lxc_conf = NULL;
}
}
static bool lxcapi_destroy(struct lxc_container *c);
/*
* lxcapi_create:
......@@ -1280,9 +1288,7 @@ static bool lxcapi_create(struct lxc_container *c, const char *t,
// now clear out the lxc_conf we have, reload from the created
// container
if (c->lxc_conf)
lxc_conf_free(c->lxc_conf);
c->lxc_conf = NULL;
lxcapi_clear_config(c);
if (t) {
if (!prepend_lxc_header(c->configfile, tpath, argv)) {
......@@ -3093,8 +3099,7 @@ struct lxc_container *lxc_container_new(const char *name, const char *configpath
if (ongoing_create(c) == 2) {
ERROR("Error: %s creation was not completed", c->name);
lxcapi_destroy(c);
lxc_conf_free(c->lxc_conf);
c->lxc_conf = NULL;
lxcapi_clear_config(c);
}
// assign the member functions
......@@ -3122,6 +3127,7 @@ struct lxc_container *lxc_container_new(const char *name, const char *configpath
c->createl = lxcapi_createl;
c->shutdown = lxcapi_shutdown;
c->reboot = lxcapi_reboot;
c->clear_config = lxcapi_clear_config;
c->clear_config_item = lxcapi_clear_config_item;
c->get_config_item = lxcapi_get_config_item;
c->get_cgroup_item = lxcapi_get_cgroup_item;
......
......@@ -85,6 +85,8 @@ struct lxc_container {
bool (*reboot)(struct lxc_container *c);
/* send SIGPWR. if timeout is not 0 or -1, do a hard stop after timeout seconds */
bool (*shutdown)(struct lxc_container *c, int timeout);
/* completely clear a configuration */
void (*clear_config)(struct lxc_container *c);
/* clear all network or capability items in the in-memory configuration */
bool (*clear_config_item)(struct lxc_container *c, const char *key);
/* print a config item to a in-memory string allocated by the caller. Return
......
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