mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-15 07:20:26 +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
|
||||
|
||||
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 $datacenterconfig = cfs_read_file('datacenter.cfg');
|
||||
# if not set by user spawn max cpu count number of workers
|
||||
my $maxWorkers = $datacenterconfig->{max_workers} || $cpuinfo->{cpus};
|
||||
|
||||
for my $order (sort {$b <=> $a} keys %$stopList) {
|
||||
my $vmlist = $stopList->{$order};
|
||||
for my $order (sort {$b <=> $a} keys %$toSuspendList) {
|
||||
my $vmlist = $toSuspendList->{$order};
|
||||
my $workers = {};
|
||||
|
||||
my $finish_worker = sub {
|
||||
@ -2106,10 +2106,10 @@ __PACKAGE__->register_method ({
|
||||
next if !$task;
|
||||
|
||||
my $pid = $task->{pid};
|
||||
|
||||
$workers->{$pid} = { type => $d->{type}, upid => $upid, vmid => $vmid };
|
||||
|
||||
while (scalar(keys %$workers) >= $maxWorkers) {
|
||||
foreach my $p (keys %$workers) {
|
||||
for my $p (keys %$workers) {
|
||||
if (!PVE::ProcFSTools::check_process_running($p)) {
|
||||
$finish_worker->($p);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user