]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Make LXC_CLONE_KEEPNAME work
authorChristian Brauner <christianvanbrauner@gmail.com>
Fri, 7 Aug 2015 23:31:21 +0000 (01:31 +0200)
committerChristian Brauner <christianvanbrauner@gmail.com>
Sat, 8 Aug 2015 00:35:03 +0000 (02:35 +0200)
Passing the LXC_CLONE_KEEPNAME flag to do_lxcapi_clone() was not respected. We
wrap clear_unexp_config_line() and set_config_item_line() in an appropriate
if-condition.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
src/lxc/lxccontainer.c

index 1c103e8283e755b7a81756b0a42dabb7c9aa618a..bf942ac1ff4b2250d19eb168bbcbfdfb91a25a65 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