[pve-devel] [PATCH pve-container 1/2] Test for arguments at beginning of 'pct exec'

Emmanuel Kasper e.kasper at proxmox.com
Wed Dec 13 12:28:32 CET 2017


Also derefence the given parameters once, for readability

Signed-off-by: Emmanuel Kasper <e.kasper at proxmox.com>
---
 src/PVE/CLI/pct.pm | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
index 05fcb29..1818551 100755
--- a/src/PVE/CLI/pct.pm
+++ b/src/PVE/CLI/pct.pm
@@ -184,13 +184,14 @@ __PACKAGE__->register_method ({
     code => sub {
 	my ($param) = @_;
 
+	my $vmid = $param->{vmid};
+	my @args = @{$param->{'extra-args'}};
+	die "missing command" if !@args;
+
 	# test if container exists on this node
-	PVE::LXC::Config->load_config($param->{vmid});
+	PVE::LXC::Config->load_config($vmid);
 
-	if (!@{$param->{'extra-args'}}) {
-	    die "missing command";
-	}
-	exec('lxc-attach', '-n', $param->{vmid}, '--', @{$param->{'extra-args'}});
+	exec('lxc-attach', '-n', $param->{vmid}, '--', @args);
     }});
 
 __PACKAGE__->register_method ({
-- 
2.11.0





More information about the pve-devel mailing list