mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-15 09:22:03 +00:00
api: bulk suspension: code clean-ups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
ebb71cb505
commit
84e1e9d996
@ -2072,15 +2072,15 @@ __PACKAGE__->register_method ({
|
|||||||
|
|
||||||
$rpcenv->{type} = 'priv'; # to start tasks in background
|
$rpcenv->{type} = 'priv'; # to start tasks in background
|
||||||
|
|
||||||
my $stopList = $get_start_stop_list->($nodename, undef, $param->{vms});
|
my $toSuspendList = $get_start_stop_list->($nodename, undef, $param->{vms});
|
||||||
|
|
||||||
my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
|
my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
|
||||||
my $datacenterconfig = cfs_read_file('datacenter.cfg');
|
my $datacenterconfig = cfs_read_file('datacenter.cfg');
|
||||||
# if not set by user spawn max cpu count number of workers
|
# if not set by user spawn max cpu count number of workers
|
||||||
my $maxWorkers = $datacenterconfig->{max_workers} || $cpuinfo->{cpus};
|
my $maxWorkers = $datacenterconfig->{max_workers} || $cpuinfo->{cpus};
|
||||||
|
|
||||||
for my $order (sort {$b <=> $a} keys %$stopList) {
|
for my $order (sort {$b <=> $a} keys %$toSuspendList) {
|
||||||
my $vmlist = $stopList->{$order};
|
my $vmlist = $toSuspendList->{$order};
|
||||||
my $workers = {};
|
my $workers = {};
|
||||||
|
|
||||||
my $finish_worker = sub {
|
my $finish_worker = sub {
|
||||||
@ -2106,10 +2106,10 @@ __PACKAGE__->register_method ({
|
|||||||
next if !$task;
|
next if !$task;
|
||||||
|
|
||||||
my $pid = $task->{pid};
|
my $pid = $task->{pid};
|
||||||
|
|
||||||
$workers->{$pid} = { type => $d->{type}, upid => $upid, vmid => $vmid };
|
$workers->{$pid} = { type => $d->{type}, upid => $upid, vmid => $vmid };
|
||||||
|
|
||||||
while (scalar(keys %$workers) >= $maxWorkers) {
|
while (scalar(keys %$workers) >= $maxWorkers) {
|
||||||
foreach my $p (keys %$workers) {
|
for my $p (keys %$workers) {
|
||||||
if (!PVE::ProcFSTools::check_process_running($p)) {
|
if (!PVE::ProcFSTools::check_process_running($p)) {
|
||||||
$finish_worker->($p);
|
$finish_worker->($p);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user