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

Oguz Bektas o.bektas at proxmox.com
Tue Nov 19 18:37:02 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, 8 insertions(+), 1 deletion(-)

diff --git a/src/lxc-pve-prestart-hook b/src/lxc-pve-prestart-hook
index c0965ab..b44b69a 100755
--- a/src/lxc-pve-prestart-hook
+++ b/src/lxc-pve-prestart-hook
@@ -29,11 +29,18 @@ 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);
+    my $storage_cfg = PVE::Storage::config();
+
+    # apply pending changes if present
+    if ($conf->{pending}) {
+	PVE::LXC::Config->vmconfig_apply_pending($vmid, $conf, $storage_cfg);
+	$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);
     }
 
-    my $storage_cfg = PVE::Storage::config();
 
     my $vollist = PVE::LXC::Config->get_vm_volumes($conf);
     my $loopdevlist = PVE::LXC::Config->get_vm_volumes($conf, 'rootfs');
-- 
2.20.1




More information about the pve-devel mailing list