]> git.proxmox.com Git - pve-container.git/commitdiff
add new option 'cores' to restrict visible cores
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 27 Oct 2016 05:13:52 +0000 (07:13 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 27 Oct 2016 10:29:19 +0000 (12:29 +0200)
Actual restriction is done by pvestatd.

src/PVE/LXC.pm
src/PVE/LXC/Config.pm

index 535147fa97a2c45c7d53546ecbe7e195f3753d96..bb577faa58f1db2c1127d7111d0b0dd3fc21c0c0 100644 (file)
@@ -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']);
index 8680ba1de8591ced96973abed4b4a4db6a3c2f0b..608653ded0cb61b3f8e7f2daf6673894152ee586 100644 (file)
@@ -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);