]> git.proxmox.com Git - pve-container.git/commitdiff
apply pending changes in lxc poststop hook
authorOguz Bektas <o.bektas@proxmox.com>
Thu, 21 Nov 2019 16:48:06 +0000 (17:48 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 21 Nov 2019 16:52:23 +0000 (17:52 +0100)
apply pending changes after container is stopped (via API or systemctl), and
update lxc config.

also affects reboots from inside the container. (but in that case we don't try
to update_lxc_config again if pending changes were already applied and lxc config
was updated)

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
src/lxc-pve-poststop-hook

index 19d0b5216a0c556aaeae206723ca560f1a637038..64fe54d9dbbed38ba97cd5e5ef8df8b5d5e411a6 100755 (executable)
@@ -38,6 +38,14 @@ PVE::LXC::Tools::lxc_hook('post-stop', 'lxc', sub {
        PVE::Network::veth_delete("veth${vmid}i$ind");
     }
 
+    my $config_updated = 0;
+    if ($conf->{pending}) {
+       PVE::LXC::Config->vmconfig_apply_pending($vmid, $conf, $storage_cfg);
+       PVE::LXC::update_lxc_config($vmid, $conf);
+       $config_updated = 1;
+    }
+
+
     my $target = $vars->{TARGET};
     if ($target && $target eq 'reboot') {
        # In order to make sure hot-plugged config changes aren't reverted
@@ -47,7 +55,7 @@ PVE::LXC::Tools::lxc_hook('post-stop', 'lxc', sub {
        # task, note that we must not block because we're part of the
        # service cgroup systemd waits for to die before issuing the new
        # lxc-start command.
-       PVE::LXC::update_lxc_config($vmid, $conf);
+       PVE::LXC::update_lxc_config($vmid, $conf) if !$config_updated;
        # Tell the post-stop hook we want to be restarted.
        open(my $fh, '>', "/var/lib/lxc/$vmid/reboot")
            or die "failed to create reboot trigger file: $!\n";