[libvirt] [PATCH 3/3] util: virsysinfo: parse frequency information on S390

Bjoern Walk bwalk at linux.vnet.ibm.com
Tue Dec 19 10:08:02 UTC 2017


Let's also parse the available processor frequency information on S390
so that it can be utilized by virsh sysinfo:

    # virsh sysinfo

    <sysinfo type='smbios'>
      ...
      <processor>
	<entry name='family'>2964</entry>
	<entry name='manufacturer'>IBM/S390</entry>
	<entry name='version'>00</entry>
	<entry name='external_clock'>5000</entry>
	<entry name='max_speed'>5000</entry>
	<entry name='serial_number'>145F07</entry>
      </processor>
      ...
    </sysinfo>

Reviewed-by: Marc Hartmayer <mhartmay at linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy at linux.vnet.ibm.com>
Signed-off-by: Bjoern Walk <bwalk at linux.vnet.ibm.com>
---
 src/util/virsysinfo.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index ab81b1f7..0c2267e3 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -495,6 +495,7 @@ virSysinfoParseS390Processor(const char *base, virSysinfoDefPtr ret)
     char *tmp_base;
     char *manufacturer = NULL;
     char *procline = NULL;
+    char *ncpu = NULL;
     int result = -1;
     virSysinfoProcessorDefPtr processor;
 
@@ -524,11 +525,41 @@ virSysinfoParseS390Processor(const char *base, virSysinfoDefPtr ret)
 
         VIR_FREE(procline);
     }
+
+    /* now, for each processor found, extract the frequency information */
+    tmp_base = (char *) base;
+
+    while ((tmp_base = strstr(tmp_base, "cpu number")) &&
+           (tmp_base = virSysinfoParseS390Line(tmp_base, "cpu number", &ncpu))) {
+        unsigned int n;
+        char *mhz = NULL;
+
+        if (virStrToLong_ui(ncpu, NULL, 10, &n) < 0 || n >= ret->nprocessor)
+            goto cleanup;
+
+        if (!(tmp_base = strstr(tmp_base, "cpu MHz dynamic")) ||
+            !virSysinfoParseS390Line(tmp_base, "cpu MHz dynamic", &mhz) ||
+            !mhz)
+            goto cleanup;
+
+        ret->processor[n].processor_external_clock = mhz;
+
+        if (!(tmp_base = strstr(tmp_base, "cpu MHz static")) ||
+            !virSysinfoParseS390Line(tmp_base, "cpu MHz static", &mhz) ||
+            !mhz)
+            goto cleanup;
+
+        ret->processor[n].processor_max_speed = mhz;
+
+        VIR_FREE(ncpu);
+    }
+
     result = 0;
 
  cleanup:
     VIR_FREE(manufacturer);
     VIR_FREE(procline);
+    VIR_FREE(ncpu);
     return result;
 }
 
-- 
2.13.4




More information about the libvir-list mailing list