]> git.proxmox.com Git - pve-container.git/blobdiff - src/PVE/CLI/pct.pm
fix #3917: Ignore fstrim failure in pct fstrim
[pve-container.git] / src / PVE / CLI / pct.pm
index e881f188111629bd6e86ed919f8eaac2a0471c15..23793ee6482ec3743c42ce14eb117c7f5f16fa8e 100755 (executable)
@@ -3,24 +3,25 @@ package PVE::CLI::pct;
 use strict;
 use warnings;
 
-use POSIX;
 use Fcntl;
 use File::Copy 'copy';
+use POSIX;
 
-use PVE::GuestHelpers;
-use PVE::SafeSyslog;
-use PVE::Tools qw(extract_param);
-use PVE::CpuSet;
+use PVE::CLIHandler;
 use PVE::Cluster;
+use PVE::CpuSet;
+use PVE::GuestHelpers;
 use PVE::INotify;
-use PVE::RPCEnvironment;
 use PVE::JSONSchema qw(get_standard_option);
-use PVE::CLIHandler;
-use PVE::API2::LXC;
+use PVE::LXC::CGroup;
+use PVE::RPCEnvironment;
+use PVE::SafeSyslog;
+use PVE::Tools qw(extract_param);
+
 use PVE::API2::LXC::Config;
-use PVE::API2::LXC::Status;
 use PVE::API2::LXC::Snapshot;
-use PVE::LXC::CGroup;
+use PVE::API2::LXC::Status;
+use PVE::API2::LXC;
 
 use base qw(PVE::CLIHandler);
 
@@ -29,7 +30,7 @@ my $nodename = PVE::INotify::nodename();
 my $upid_exit = sub {
     my $upid = shift;
     my $status = PVE::Tools::upid_read_status($upid);
-    exit($status eq 'OK' ? 0 : -1);
+    exit(PVE::Tools::upid_status_is_error($status) ? -1 : 0);
 };
 
 sub setup_environment {
@@ -710,10 +711,10 @@ __PACKAGE__->register_method ({
            my $cgroup = PVE::LXC::CGroup->new($vmid);
 
            my ($cpuset, $path);
-           if (defined($path = $cgroup->get_path('cpuset'))) {
-               $cpuset = eval { PVE::CpuSet->new_from_path($path); };
-           } elsif (defined($path = $cgroup->get_path())) {
-               $cpuset = eval { PVE::CpuSet->new_from_path($path); };
+           if (defined($path = $cgroup->get_path('cpuset', 1))) {
+               $cpuset = eval { PVE::CpuSet->new_from_path($path, 1); };
+           } elsif (defined($path = $cgroup->get_path(undef, 1))) {
+               $cpuset = eval { PVE::CpuSet->new_from_path($path, 1); };
            } else {
                # Container not running.
                next;
@@ -791,7 +792,7 @@ __PACKAGE__->register_method ({
                $path = $mp->{mp};
                return if $param->{'ignore-mountpoints'} && $name =~ /^mp\d+/;
                my $cmd = ["fstrim", "-v", "$rootdir$path"];
-               PVE::Tools::run_command($cmd);
+               PVE::Tools::run_command($cmd, noerr => 1);
            });
        };
        warn $@ if $@;
@@ -848,7 +849,8 @@ our $cmddef = {
 
     clone => [ "PVE::API2::LXC", 'clone_vm', ['vmid', 'newid'], { node => $nodename }, $upid_exit ],
     migrate => [ "PVE::API2::LXC", 'migrate_vm', ['vmid', 'target'], { node => $nodename }, $upid_exit],
-    move_volume => [ "PVE::API2::LXC", 'move_volume', ['vmid', 'volume', 'storage'], { node => $nodename }, $upid_exit ],
+    'move-volume' => [ "PVE::API2::LXC", 'move_volume', ['vmid', 'volume', 'storage', 'target-vmid', 'target-volume'], { node => $nodename }, $upid_exit ],
+    move_volume => { alias => 'move-volume' },
 
     snapshot => [ "PVE::API2::LXC::Snapshot", 'snapshot', ['vmid', 'snapname'], { node => $nodename } , $upid_exit ],
     delsnapshot => [ "PVE::API2::LXC::Snapshot", 'delsnapshot', ['vmid', 'snapname'], { node => $nodename } , $upid_exit ],
@@ -874,5 +876,4 @@ our $cmddef = {
     fstrim => [ __PACKAGE__, 'fstrim', ['vmid']],
 };
 
-
 1;