See [0] for the details. The call tree for the variants is
lock_config -> lock_config_full -> lock_config_mode
so it is sufficient to adapt lock_config_mode.

[0]: https://bugzilla.proxmox.com/show_bug.cgi?id=2682

Suggested-by: Fabian Grünbichler <f.gruenbich...@proxmox.com>
Signed-off-by: Fabian Ebner <f.eb...@proxmox.com>
---

Note that @param is passed along to lock_file_full but also already
used directly in the closure. This (cosmetic) issue is addressed as
part of Fabian G.'s patch #9

 PVE/AbstractConfig.pm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/PVE/AbstractConfig.pm b/PVE/AbstractConfig.pm
index f1b395c..15368de 100644
--- a/PVE/AbstractConfig.pm
+++ b/PVE/AbstractConfig.pm
@@ -292,7 +292,13 @@ sub lock_config_mode {
 
     my $filename = $class->config_file_lock($vmid);
 
-    my $res = lock_file_full($filename, $timeout, $shared, $code, @param);
+    # make sure configuration file is up-to-date
+    my $realcode = sub {
+       PVE::Cluster::cfs_update();
+       $code->(@param);
+    };
+
+    my $res = lock_file_full($filename, $timeout, $shared, $realcode, @param);
 
     die $@ if $@;
 
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to