]> git.proxmox.com Git - pve-container.git/blobdiff - src/PVE/CLI/pct.pm
pct enter: check if container runs before lxc-attach
[pve-container.git] / 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 ({