This is an automated email from the ASF dual-hosted git repository.

nvazquez pushed a commit to branch 4.22
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.22 by this push:
     new 17098c15eb3 Fix lscpu speed checking order (#12190)
17098c15eb3 is described below

commit 17098c15eb322220a9fde12b8156f3aa1c195641
Author: Guillem <[email protected]>
AuthorDate: Thu Sep 10 11:56:22 2026 +0200

    Fix lscpu speed checking order (#12190)
---
 .../org/apache/cloudstack/utils/linux/KVMHostInfo.java     | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git 
a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
 
b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
index db665c75cc1..d8e5bed2ef0 100644
--- 
a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
+++ 
b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
@@ -140,21 +140,21 @@ public class KVMHostInfo {
         long speed = 0L;
         LOGGER.info("Fetching CPU speed from command \"lscpu\".");
         try {
-            String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep 
-o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";
-            if(isHostS390x()) {
-                command = "lscpu | grep 'CPU dynamic MHz' | cut -d ':' -f 2 | 
tr -d ' ' | awk '{printf \"%.1f\\n\", $1 / 1000}'";
-            }
+            String command = "lscpu | grep -i 'CPU max MHz' | head -n 1 | sed 
's/^.*: //' | xargs";
             String result = Script.runSimpleBashScript(command);
-            speed = (long) (Float.parseFloat(result) * 1000);
+            speed = (long) (Float.parseFloat(result));
             LOGGER.info(String.format("Command [%s] resulted in the value [%s] 
for CPU speed.", command, speed));
             return speed;
         } catch (NullPointerException | NumberFormatException e) {
             LOGGER.error(String.format("Unable to retrieve the CPU speed from 
lscpu."), e);
         }
         try {
-            String command = "lscpu | grep -i 'CPU max MHz' | head -n 1 | sed 
's/^.*: //' | xargs";
+            String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep 
-o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";
+            if(isHostS390x()) {
+                command = "lscpu | grep 'CPU dynamic MHz' | cut -d ':' -f 2 | 
tr -d ' ' | awk '{printf \"%.1f\\n\", $1 / 1000}'";
+            }
             String result = Script.runSimpleBashScript(command);
-            speed = (long) (Float.parseFloat(result));
+            speed = (long) (Float.parseFloat(result) * 1000);
             LOGGER.info(String.format("Command [%s] resulted in the value [%s] 
for CPU speed.", command, speed));
             return speed;
         } catch (NullPointerException | NumberFormatException e) {

Reply via email to