[pve-devel] [PATCH v3 container 2/2] clear machine-id also after container clone

Oguz Bektas o.bektas at proxmox.com
Thu May 27 11:26:01 CEST 2021


pass $clone=1 to avoid removing the file. instead we truncate it to an
empty file

Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
v2->v3:
* clear machine-id at the end of clone task worker

 src/PVE/API2/LXC.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index a9ea3a6..d5c12dc 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1590,6 +1590,12 @@ __PACKAGE__->register_method({
 		die "clone failed: $err";
 	    }
 
+	    my $lastconf = PVE::LXC::Config->load_config($newid);
+	    my $rootdir = PVE::LXC::mount_all($newid, $storecfg, $lastconf, 1);
+	    my $lxc_setup = PVE::LXC::Setup->new($lastconf, $rootdir);
+	    $lxc_setup->clear_machine_id($lastconf, 1);
+	    PVE::LXC::umount_all($newid, $storecfg, $lastconf, 1);
+
 	    return;
 	};
 
-- 
2.20.1






More information about the pve-devel mailing list