You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2021/06/17 07:51:54 UTC
[cloudstack] branch main updated: kvm: Improve logs on agent start
(#4958)
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push:
new 2ececbf kvm: Improve logs on agent start (#4958)
2ececbf is described below
commit 2ececbf9942f966e9a637d758c66c073599de988
Author: Daniel Augusto Veronezi Salvador <38...@users.noreply.github.com>
AuthorDate: Thu Jun 17 04:51:30 2021 -0300
kvm: Improve logs on agent start (#4958)
This PR intends to improve logging on agent start to facilitate troubleshooting.
Co-authored-by: Daniel Augusto Veronezi Salvador <da...@scclouds.com.br>
Co-authored-by: sureshanaparti <12...@users.noreply.github.com>
---
.../java/org/apache/cloudstack/utils/linux/KVMHostInfo.java | 11 +++++++----
1 file changed, 7 insertions(+), 4 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 1f28304..60e98f5 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
@@ -42,6 +42,8 @@ public class KVMHostInfo {
private long overCommitMemory;
private List<String> capabilities = new ArrayList<>();
+ private static String cpuInfoMaxFreqFileName = "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq";
+
public KVMHostInfo(long reservedMemory, long overCommitMemory) {
this.reservedMemory = reservedMemory;
this.overCommitMemory = overCommitMemory;
@@ -78,11 +80,12 @@ public class KVMHostInfo {
}
protected static long getCpuSpeed(final NodeInfo nodeInfo) {
- try (final Reader reader = new FileReader(
- "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq")) {
- return Long.parseLong(IOUtils.toString(reader).trim()) / 1000;
+ try (Reader reader = new FileReader(cpuInfoMaxFreqFileName)) {
+ Long cpuInfoMaxFreq = Long.parseLong(IOUtils.toString(reader).trim());
+ LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
+ return cpuInfoMaxFreq / 1000;
} catch (IOException | NumberFormatException e) {
- LOGGER.info("Could not read cpuinfo_max_freq, falling back on libvirt");
+ LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
return nodeInfo.mhz;
}
}