Skip to content

Commit

Permalink
Make LXC_CLONE_KEEPNAME work
Browse files Browse the repository at this point in the history
- Passing the LXC_CLONE_KEEPNAME flag to do_lxcapi_clone() was not respected and
  let to unexpected behaviour for e.g. lxc-clone. We wrap
  clear_unexp_config_line() and set_config_item_line() in an appropriate
  if-condition.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
  • Loading branch information
brauner authored and stgraber committed Aug 27, 2015
1 parent dea53c2 commit 65f51ca
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lxc/lxccontainer.c
Expand Up @@ -2873,12 +2873,15 @@ static struct lxc_container *do_lxcapi_clone(struct lxc_container *c, const char
if (ret < 0)
goto out;

clear_unexp_config_line(c2->lxc_conf, "lxc.utsname", false);

// update utsname
if (!set_config_item_locked(c2, "lxc.utsname", newname)) {
ERROR("Error setting new hostname");
goto out;
if (!(flags & LXC_CLONE_KEEPNAME)) {
clear_unexp_config_line(c2->lxc_conf, "lxc.utsname", false);

if (!set_config_item_locked(c2, "lxc.utsname", newname)) {
ERROR("Error setting new hostname");
goto out;
}
}

// copy hooks
Expand Down

0 comments on commit 65f51ca

Please sign in to comment.