- 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 <christianvanbrau...@gmail.com>
---
 src/lxc/lxccontainer.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 4918aab..5291634 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -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
-- 
2.5.0

_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to