You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2020/06/30 02:18:37 UTC

[GitHub] [cloudstack] GabrielBrascher commented on a change in pull request #4178: add kvm vcpu socket and threads config

GabrielBrascher commented on a change in pull request #4178:
URL: https://github.com/apache/cloudstack/pull/4178#discussion_r447212031



##########
File path: plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
##########
@@ -2297,12 +2297,32 @@ public LibvirtVMDef createVMFromSpec(final VirtualMachineTO vmTO) {
                 cmd.setFeatures(_cpuFeatures);
             }
             // multi cores per socket, for larger core configs
-            if (vcpus % 6 == 0) {
-                final int sockets = vcpus / 6;
-                cmd.setTopology(6, sockets);
-            } else if (vcpus % 4 == 0) {
-                final int sockets = vcpus / 4;
-                cmd.setTopology(4, sockets);
+            String coresPerSocket = null;
+            Boolean coresthreads = null;
+            if (vmTO.getDetails() != null) {
+                coresPerSocket = vmTO.getDetails().get(VmDetailConstants.CPU_CORE_PER_SOCKET);
+                coresthreads = Boolean.valueOf(vmTO.getDetails().get(VmDetailConstants.CPU_HYPERTHREADING));
+
+                s_logger.debug("user custom set coresPerSocket:" + coresPerSocket + ", coresThreads:" + coresthreads + "  ,   vmTO:" + vmTO.getUuid());
+            }
+            if (coresPerSocket != null) {
+                final int numCoresPerSocket = NumbersUtil.parseInt(coresPerSocket, 1);
+                if (vcpus % numCoresPerSocket == 0) {
+                    final int sockets = vcpus / numCoresPerSocket;
+                    if(coresthreads && numCoresPerSocket % 2 == 0) {
+                        cmd.setTopology(numCoresPerSocket /2, sockets,2);
+                    } else {
+                        cmd.setTopology(numCoresPerSocket, sockets);
+                    }
+                }
+            } else {
+                if (vcpus % 6 == 0) {
+                    final int sockets = vcpus / 6;
+                    cmd.setTopology(6, sockets);
+                } else if (vcpus % 4 == 0) {
+                    final int sockets = vcpus / 4;
+                    cmd.setTopology(4, sockets);
+                }

Review comment:
       What do you think of extracting lines 2300 - 2325 into a method? That would allow adding Javadoc and UNIT test.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org