File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 1717package com .cloud .hypervisor ;
1818
1919import java .util .ArrayList ;
20+ import java .util .Comparator ;
2021import java .util .List ;
2122import java .util .Map ;
2223
@@ -95,7 +96,14 @@ public VirtualMachineTO implement(VirtualMachineProfile vm) {
9596 if (userVmVO != null ) {
9697 HostVO host = hostDao .findById (userVmVO .getHostId ());
9798 if (host != null ) {
98- to .setVcpuMaxLimit (MaxNumberOfVCPUSPerVM .valueIn (host .getClusterId ()));
99+ List <HostVO > clusterHosts = hostDao .listByClusterAndHypervisorType (host .getClusterId (), host .getHypervisorType ());
100+ HostVO hostWithMinSocket = clusterHosts .stream ().min (Comparator .comparing (HostVO ::getCpuSockets )).orElse (null );
101+ Integer vCpus = MaxNumberOfVCPUSPerVM .valueIn (host .getClusterId ());
102+ if (hostWithMinSocket != null && hostWithMinSocket .getCpuSockets () != null &&
103+ hostWithMinSocket .getCpuSockets () < vCpus ) {
104+ vCpus = hostWithMinSocket .getCpuSockets ();
105+ }
106+ to .setVcpuMaxLimit (vCpus );
99107 }
100108 }
101109
You can’t perform that action at this time.
0 commit comments