/** * Computes the maximum allowed number of vCPUs that can be assigned * to a VM according to the specified compatibility level. * * @param vmTemplate The VM template for which we want to know the maximum * @param compatibilityVersion The compatibility level * @return The maximum supported number of vCPUs */ public static Integer calcMaxVCpu(VmTemplate vmTemplate, Version compatibilityVersion) { return calcMaxVCpu(vmTemplate, compatibilityVersion, architectureFamily(vmTemplate)); }
/** * Computes the maximum allowed number of vCPUs that can be assigned * to a VM according to the specified compatibility level. * * @param vm The VM for which we want to know the maximum * @param compatibilityVersion The compatibility level * @return The maximum supported number of vCPUs */ public static Integer calcMaxVCpu(VM vm, Version compatibilityVersion) { return calcMaxVCpu(vm.getStaticData(), compatibilityVersion, architectureFamily(vm)); }
/** * Validates CPU count configuration. It may not be possible to use * configurations with too many threads or cores. * * @param vm The VM for which we want to check the CPU count configuration * @return Whether the CPU count configuration is valid */ public static boolean validateCpuCounts(VM vm) { ArchitectureType architecture = architectureFamily(vm); if (architecture == null || architecture == ArchitectureType.x86) { return bitWidth(vm.getThreadsPerCpu()) + bitWidth(vm.getCpuPerSocket()) <= maxBitWidth; } return true; } }