mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-30 11:30:53 +00:00
cpulimit: use number instead of integer
This commit is contained in:
parent
58be00f10a
commit
c6f773b818
@ -122,9 +122,10 @@ my $confdesc = {
|
|||||||
},
|
},
|
||||||
cpulimit => {
|
cpulimit => {
|
||||||
optional => 1,
|
optional => 1,
|
||||||
type => 'integer',
|
type => 'number',
|
||||||
description => "Limit of CPU usage in per cent. Note if the computer has 2 CPUs, it has total of 200% CPU time. Value '0' indicates no CPU limit.\n\n.",
|
description => "Limit of CPU usage. Note if the computer has 2 CPUs, it has total of '2' CPU time. Value '0' indicates no CPU limit.",
|
||||||
minimum => 0,
|
minimum => 0,
|
||||||
|
maximum => 128,
|
||||||
default => 0,
|
default => 0,
|
||||||
},
|
},
|
||||||
cpuunits => {
|
cpuunits => {
|
||||||
@ -2563,8 +2564,8 @@ sub config_to_command {
|
|||||||
push @$cmd, '--unit', $vmid;
|
push @$cmd, '--unit', $vmid;
|
||||||
push @$cmd, '-p', "CPUShares=$cpuunits";
|
push @$cmd, '-p', "CPUShares=$cpuunits";
|
||||||
if ($conf->{cpulimit}) {
|
if ($conf->{cpulimit}) {
|
||||||
my $cpulimit = $conf->{cpulimit} * 100;
|
my $cpulimit = int($conf->{cpulimit} * 100);
|
||||||
push @$cmd, '-p', "CPUQuota=$cpulimit"."\%";
|
push @$cmd, '-p', "CPUQuota=$cpulimit\%";
|
||||||
}
|
}
|
||||||
|
|
||||||
push @$cmd, '/usr/bin/kvm';
|
push @$cmd, '/usr/bin/kvm';
|
||||||
@ -3893,7 +3894,7 @@ sub vmconfig_hotplug_pending {
|
|||||||
} elsif ($opt eq 'cpuunits') {
|
} elsif ($opt eq 'cpuunits') {
|
||||||
cgroups_write("cpu", $vmid, "cpu.shares", $conf->{pending}->{$opt});
|
cgroups_write("cpu", $vmid, "cpu.shares", $conf->{pending}->{$opt});
|
||||||
} elsif ($opt eq 'cpulimit') {
|
} elsif ($opt eq 'cpulimit') {
|
||||||
my $cpulimit = $conf->{pending}->{$opt} == 0 ? -1 : $conf->{pending}->{$opt} * 100000;
|
my $cpulimit = $conf->{pending}->{$opt} == 0 ? -1 : int($conf->{pending}->{$opt} * 100000);
|
||||||
cgroups_write("cpu", $vmid, "cpu.cfs_quota_us", $cpulimit);
|
cgroups_write("cpu", $vmid, "cpu.cfs_quota_us", $cpulimit);
|
||||||
} else {
|
} else {
|
||||||
die "skip\n"; # skip non-hot-pluggable options
|
die "skip\n"; # skip non-hot-pluggable options
|
||||||
|
Loading…
Reference in New Issue
Block a user