]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Make LXC_CLONE_KEEPNAME work
authorChristian Brauner <christianvanbrauner@gmail.com>
Fri, 14 Aug 2015 18:17:21 +0000 (20:17 +0200)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 27 Aug 2015 20:14:08 +0000 (15:14 -0500)
- 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>
src/lxc/lxccontainer.c

index 4918aabad8c6a591b811ea07e0383ea452165b1b..529163449ee36b0107186ff3ca7b3a652f923749 100644 (file)
@@ -2906,12 +2906,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