[pve-devel] [PATCH v5 container 3/4] run post_clone_hook in clone_vm API

Oguz Bektas o.bektas at proxmox.com
Thu Jun 17 12:52:00 CEST 2021


Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
v4->v5:
* no change


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

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index ade109b..c2312f4 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1554,6 +1554,15 @@ __PACKAGE__->register_method({
 		}
 
 		PVE::AccessControl::add_vm_to_pool($newid, $pool) if $pool;
+
+		$newconf = PVE::LXC::Config->load_config($newid);
+		die "Lost 'create' config lock, aborting.\n"
+		    if !PVE::LXC::Config->has_lock($newconf, 'create');
+		my $rootdir = PVE::LXC::mount_all($newid, $storecfg, $newconf, 1);
+		my $lxc_setup = PVE::LXC::Setup->new($newconf, $rootdir);
+		$lxc_setup->post_clone_hook($newconf);
+		PVE::LXC::umount_all($newid, $storecfg, $newconf, 1);
+
 		PVE::LXC::Config->remove_lock($newid, 'create');
 
 		PVE::LXC::Config->lock_config($newid, sub {
-- 
2.20.1






More information about the pve-devel mailing list