Before, if an invalid/non-existant ostemplate parameter was passed,
the task would abort, but would leave an empty config file behind.
This also applies to errors for invalid mount point configurations.
In both cases, the empty config will now be removed.

Signed-off-by: Daniel Tschlatscher <d.tschlatsc...@proxmox.com>
---
 src/PVE/API2/LXC.pm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 79aecaa..7cc64af 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -443,7 +443,14 @@ __PACKAGE__->register_method({
                    }
                }
            };
-           die "$emsg $@" if $@;
+
+           if (my $reason = $@) {
+               if (!$same_container_exists) {
+                   eval { PVE::LXC::Config->destroy_config($vmid) };
+                   $remove_lock = 0;
+               }
+               die "$emsg $reason";
+           }
 
            # up until here we did not modify the container, besides the lock
            $remove_lock = 0;
-- 
2.30.2



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

Reply via email to