[pve-devel] [PATCH container] pct enter: check if container runs before lxc-attach

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Feb 24 09:33:41 CET 2016


else we get:
 >
 > lxc-attach: attach.c: lxc_attach: 710 failed to get the init pid

which an arbitrary user could misunderstand.
---
 src/PVE/CLI/pct.pm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
index b2bc361..432da39 100755
--- a/src/PVE/CLI/pct.pm
+++ b/src/PVE/CLI/pct.pm
@@ -92,10 +92,14 @@ __PACKAGE__->register_method ({
     code => sub {
 	my ($param) = @_;
 
+	my $vmid = $param->{vmid};
+
 	# test if container exists on this node
-	PVE::LXC::load_config($param->{vmid});
+	PVE::LXC::load_config($vmid);
+
+	die "Error: container '$vmid' not running!\n" if !PVE::LXC::check_running($vmid);
 
-	exec('lxc-attach', '-n',  $param->{vmid});
+	exec('lxc-attach', '-n',  $vmid);
     }});
 
 __PACKAGE__->register_method ({
-- 
2.1.4





More information about the pve-devel mailing list