From: Dietmar Maurer Date: Thu, 27 Oct 2016 05:13:52 +0000 (+0200) Subject: add new option 'cores' to restrict visible cores X-Git-Url: https://git.proxmox.com/?p=pve-container.git;a=commitdiff_plain;h=f2357408bbd03c4b0114338a9eb49238e2dd1ed6 add new option 'cores' to restrict visible cores Actual restriction is done by pvestatd. --- diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 535147f..bb577fa 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -147,7 +147,8 @@ sub vmstatus { $d->{name} = $conf->{'hostname'} || "CT$vmid"; $d->{name} =~ s/[\s]//g; - $d->{cpus} = $conf->{cpulimit} || $cpucount; + $d->{cpus} = $conf->{cores} || $conf->{cpulimit}; + $d->{cpus} = $cpucount if !$d->{cpus}; $d->{lock} = $conf->{lock} || ''; @@ -873,7 +874,7 @@ sub check_ct_modify_config_perm { my $check = sub { my ($opt, $delete) = @_; - if ($opt eq 'cpus' || $opt eq 'cpuunits' || $opt eq 'cpulimit') { + if ($opt eq 'cores' || $opt eq 'cpuunits' || $opt eq 'cpulimit') { $rpcenv->check_vm_perm($authuser, $vmid, $pool, ['VM.Config.CPU']); } elsif ($opt eq 'rootfs' || $opt =~ /^mp\d+$/) { $rpcenv->check_vm_perm($authuser, $vmid, $pool, ['VM.Config.Disk']); diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm index 8680ba1..608653d 100644 --- a/src/PVE/LXC/Config.pm +++ b/src/PVE/LXC/Config.pm @@ -306,6 +306,13 @@ my $confdesc = { maximum => 6, default => 2, }, + cores => { + optional => 1, + type => 'integer', + description => "The number of cores assigned to the container. A container can use all available cores by default.", + minimum => 1, + maximum => 128, + }, cpulimit => { optional => 1, type => 'number', @@ -780,6 +787,8 @@ sub update_pct_config { $opt eq 'tty' || $opt eq 'console' || $opt eq 'cmode') { next if $hotplug_error->($opt); delete $conf->{$opt}; + } elsif ($opt eq 'cores') { + delete $conf->{$opt}; # rest is handled by pvestatd } elsif ($opt eq 'cpulimit') { PVE::LXC::write_cgroup_value("cpu", $vmid, "cpu.cfs_quota_us", -1); delete $conf->{$opt}; @@ -882,6 +891,8 @@ sub update_pct_config { next if $hotplug_error->($opt); my $list = PVE::LXC::verify_searchdomain_list($value); $conf->{$opt} = $list; + } elsif ($opt eq 'cores') { + $conf->{$opt} = $value;# rest is handled by pvestatd } elsif ($opt eq 'cpulimit') { if ($value == 0) { PVE::LXC::write_cgroup_value("cpu", $vmid, "cpu.cfs_quota_us", -1);