public int getNumOfCpus(boolean countThreadsAsCPU) { return this.getCpuPerSocket() * this.getNumOfSockets() * (countThreadsAsCPU ? this.getThreadsPerCpu() : 1); }
private void writeCpu() { _writer.writeStartElement("Item"); _writer.writeElement(RASD_URI, "Caption", String.format("%1$s virtual cpu", vmBase.getNumOfCpus())); _writer.writeElement(RASD_URI, "Description", "Number of virtual CPU"); _writer.writeElement(RASD_URI, "InstanceId", String.valueOf(++_instanceId)); _writer.writeElement(RASD_URI, "ResourceType", OvfHardware.CPU); _writer.writeElement(RASD_URI, "num_of_sockets", String.valueOf(vmBase.getNumOfSockets())); _writer.writeElement(RASD_URI, "cpu_per_socket", String.valueOf(vmBase.getCpuPerSocket())); _writer.writeElement(RASD_URI, "threads_per_cpu", String.valueOf(vmBase.getThreadsPerCpu())); _writer.writeElement(RASD_URI, "max_num_of_vcpus", String.valueOf(maxNumOfVcpus())); // TODO: replace with Limit _writer.writeElement(RASD_URI, "VirtualQuantity", String.valueOf(vmBase.getNumOfCpus())); _writer.writeEndElement(); }
/** * 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 * @param architecture Architecture family of the VM * @return The maximum supported number of vCPUs */ private static Integer calcMaxVCpu(VmBase vm, Version compatibilityVersion, ArchitectureType architecture) { Integer maxSockets = Config.<Integer>getValue( ConfigValues.MaxNumOfVmSockets, compatibilityVersion.getValue()); Integer maxVCpus = Config.<Integer>getValue( ConfigValues.MaxNumOfVmCpus, compatibilityVersion.getValue()); int threadsPerCore = vm.getThreadsPerCpu(); int cpuPerSocket = vm.getCpuPerSocket(); return calcMaxVCpu(architecture, maxSockets, maxVCpus, threadsPerCore, cpuPerSocket); }
@Override protected void build(VmBase vm, UnitVmModel model) { model.getMemSize().setEntity(vm.getMemSizeMb()); model.getMaxMemorySize().setEntity(vm.getMaxMemorySizeMb() ); model.getIoThreadsEnabled().setEntity(vm.getNumOfIoThreads() != 0); model.getNumOfIoThreads().setEntity(Integer.toString(vm.getNumOfIoThreads())); model.getMinAllocatedMemory().setEntity(vm.getMinAllocatedMem()); model.getUsbPolicy().setSelectedItem(vm.getUsbPolicy()); model.getNumOfMonitors().setSelectedItem(vm.getNumOfMonitors()); model.getIsSingleQxlEnabled().setEntity(vm.getSingleQxlPci()); model.setBootSequence(vm.getDefaultBootSequence()); model.getTotalCPUCores().setEntity(Integer.toString(vm.getNumOfCpus())); model.getNumOfSockets().setSelectedItem(vm.getNumOfSockets()); model.getCoresPerSocket().setSelectedItem(vm.getCpuPerSocket()); model.getThreadsPerCore().setSelectedItem(vm.getThreadsPerCpu()); model.getIsSmartcardEnabled().setEntity(vm.isSmartcardEnabled()); model.setSelectedMigrationDowntime(vm.getMigrationDowntime()); model.selectMigrationPolicy(vm.getMigrationPolicyId()); model.getEmulatedMachine().setSelectedItem(vm.getCustomEmulatedMachine()); model.getCustomCpu().setSelectedItem(vm.getCustomCpuName()); model.getBiosType().setSelectedItem(vm.getBiosType()); } }
maybeSetSelectedItem(model.getCoresPerSocket(), vmBase.getCpuPerSocket()); maybeSetSelectedItem(model.getThreadsPerCore(), vmBase.getThreadsPerCpu());
private static VmStatic doMapVmBaseHwPartToVmStatic(VmBase entity, VmStatic staticVm, Version version) { staticVm.setMemSizeMb(entity.getMemSizeMb()); staticVm.setMaxMemorySizeMb(entity.getMaxMemorySizeMb()); staticVm.setAutoStartup(entity.isAutoStartup()); staticVm.setSmartcardEnabled(entity.isSmartcardEnabled()); staticVm.setDefaultBootSequence(entity.getDefaultBootSequence()); staticVm.setDefaultDisplayType(entity.getDefaultDisplayType()); staticVm.setNumOfSockets(entity.getNumOfSockets()); staticVm.setCpuPerSocket(entity.getCpuPerSocket()); staticVm.setThreadsPerCpu(entity.getThreadsPerCpu()); staticVm.setNumOfMonitors(entity.getNumOfMonitors()); staticVm.setSingleQxlPci(entity.getSingleQxlPci()); staticVm.setPriority(entity.getPriority()); staticVm.setUsbPolicy(entity.getUsbPolicy()); staticVm.setTunnelMigration(entity.getTunnelMigration()); staticVm.setMigrationSupport(entity.getMigrationSupport()); staticVm.setMigrationDowntime(entity.getMigrationDowntime()); staticVm.setDedicatedVmForVdsList(entity.getDedicatedVmForVdsList()); staticVm.setMinAllocatedMem(entity.getMinAllocatedMem()); staticVm.setNumOfIoThreads(entity.getNumOfIoThreads()); return staticVm; }
topology.setCores(entity.getCpuPerSocket()); topology.setThreads(entity.getThreadsPerCpu()); model.setCpu(new Cpu());
.addValue("cluster_id", entity.getClusterId()) .addValue("num_of_sockets", entity.getNumOfSockets()) .addValue("cpu_per_socket", entity.getCpuPerSocket()) .addValue("threads_per_cpu", entity.getThreadsPerCpu()) .addValue("os", entity.getOsId())
vmBase.getMaxMemorySizeMb(), vmBase.getNumOfSockets(), vmBase.getCpuPerSocket(), vmBase.getThreadsPerCpu(), vmBase.getNumOfMonitors(),
assertEquals(NUM_OF_SOCKETS, vm.getNumOfSockets()); assertTrue(vm.getThreadsPerCpu() > 0); assertEquals(TOTAL_CPU / (NUM_OF_SOCKETS * vm.getThreadsPerCpu()), vm.getCpuPerSocket()); assertTrue(vm.isDeleteProtected()); assertEquals(VNC_KEYBOARD_LAYOUT, vm.getVncKeyboardLayout());