]> git.proxmox.com Git - qemu-server.git/commitdiff
api: clone vm: comment and style clean-up deactivation error-handling
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 8 Mar 2024 12:49:03 +0000 (13:49 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 8 Mar 2024 12:51:30 +0000 (13:51 +0100)
Make the post-if check for the target not already running more
prominent by using a full if block.

Also comment on why we ignore the error here, while the commit
changing that explained it well, this is one of the things that might
be better of with a in-code comment (as doing the deactivation is
described as important here, so one might wonder why the code
continues if that fails)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Qemu.pm

index 1ff5abe40edf44274f513a7ca375a45e1772cbfd..40b6c3020982302b27d86f8d1ca462cad6315404 100644 (file)
@@ -3820,11 +3820,12 @@ __PACKAGE__->register_method({
                PVE::QemuServer::create_ifaces_ipams_ips($newconf, $newid);
 
                if ($target) {
-                   # always deactivate volumes - avoid lvm LVs to be active on several nodes
-                   eval {
-                       PVE::Storage::deactivate_volumes($storecfg, $vollist, $snapname) if !$running;
-                   };
-                   log_warn($@) if ($@);
+                   if (!$running) {
+                       # always deactivate volumes – avoids that LVM LVs are active on several nodes
+                       eval { PVE::Storage::deactivate_volumes($storecfg, $vollist, $snapname) };
+                       # but only warn when that fails (e.g., parallel clones keeping them active)
+                       log_warn($@) if $@;
+                   }
 
                    PVE::Storage::deactivate_volumes($storecfg, $newvollist);