[pve-devel] [PATCH v2 container 4/5] apply pending changes in lxc prestart hook

Oguz Bektas o.bektas at proxmox.com
Tue Nov 19 15:53:46 CET 2019


this allows pending changes to be applied when a reboot is issued inside
the container.

Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
 src/lxc-pve-prestart-hook | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/lxc-pve-prestart-hook b/src/lxc-pve-prestart-hook
index c0965ab..516217f 100755
--- a/src/lxc-pve-prestart-hook
+++ b/src/lxc-pve-prestart-hook
@@ -29,6 +29,15 @@ PVE::LXC::Tools::lxc_hook('pre-start', 'lxc', sub {
     return undef if ! -f PVE::LXC::Config->config_file($vmid);
 
     my $conf = PVE::LXC::Config->load_config($vmid);
+
+    # apply pending changes if present
+    if ($conf->{pending}) {
+	my @pending_delete = PVE::Tools::split_list($conf->{pending}->{delete});
+	PVE::LXC::Config->update_pct_config($vmid, $conf, 0, $conf->{pending}, \@pending_delete);
+	PVE::LXC::update_lxc_config($vmid, $conf);
+	$conf = PVE::LXC::Config->load_config($vmid); # just to be sure
+    }
+
     if (!$skiplock && !PVE::LXC::Config->has_lock($conf, 'mounted')) {
 	PVE::LXC::Config->check_lock($conf);
     }
-- 
2.20.1




More information about the pve-devel mailing list