[pve-devel] [PATCH container 1/2] fix: clean up config when invalid ostemplate is given

Daniel Tschlatscher d.tschlatscher at proxmox.com
Thu Nov 17 10:39:31 CET 2022


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.tschlatscher at 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






More information about the pve-devel mailing list