]> git.proxmox.com Git - pve-container.git/commitdiff
pct enter: check if container runs before lxc-attach
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 24 Feb 2016 08:33:41 +0000 (09:33 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 24 Feb 2016 09:35:49 +0000 (10:35 +0100)
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

index b2bc361149762362ae8cb8d73c0fbb1d84d64f83..432da39bdde48b6439d45d51901119d5f77acbd7 100755 (executable)
@@ -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 ({