]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
sysinfo: Fix reports on ARM
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 12 May 2015 16:21:18 +0000 (18:21 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 21 May 2015 16:13:18 +0000 (18:13 +0200)
Due to a kernel commit (b4b8f770e), cpuinfo format has changed on
ARMs. Firstly, 'Processor: ...' may not be reported, it's
replaced by 'model name: ...'. Secondly, the "Processor" string
may occur in CPU name, e.g. 'ARMv7 Processor rev 5 (v7l)'.
Therefore, we must firstly look for 'model name' and then for
'Processor' if not found.
Moreover, lines in the cpuinfo file are shuffled, so we better
not manipulate the pointer to start of internal buffer as we may
lost some info.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virsysinfo.c
tests/sysinfodata/arm-rpi2cpuinfo.data [new file with mode: 0644]
tests/sysinfodata/arm-rpi2sysinfo.expect [new file with mode: 0644]
tests/sysinfotest.c

index 8bb17f07badc956e985978cc951aecdd64e6081d..40390abaa91893696a67e4e66be8aed209cc757e 100644 (file)
@@ -289,16 +289,15 @@ virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret)
     virSysinfoProcessorDefPtr processor;
     char *processor_type = NULL;
 
-    if (!(tmp_base = strstr(base, "Processor")))
+    if (!(tmp_base = strstr(base, "model name")) &&
+        !(tmp_base = strstr(base, "Processor")))
         return 0;
 
-    base = tmp_base;
-    eol = strchr(base, '\n');
-    cur = strchr(base, ':') + 1;
+    eol = strchr(tmp_base, '\n');
+    cur = strchr(tmp_base, ':') + 1;
     virSkipSpaces(&cur);
     if (eol && VIR_STRNDUP(processor_type, cur, eol - cur) < 0)
         goto error;
-    base = cur;
 
     while ((tmp_base = strstr(base, "processor")) != NULL) {
         base = tmp_base;
diff --git a/tests/sysinfodata/arm-rpi2cpuinfo.data b/tests/sysinfodata/arm-rpi2cpuinfo.data
new file mode 100644 (file)
index 0000000..598e365
--- /dev/null
@@ -0,0 +1,43 @@
+processor       : 0
+model name      : ARMv7 Processor rev 5 (v7l)
+BogoMIPS        : 38.40
+Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
+CPU implementer : 0x41
+CPU architecture: 7
+CPU variant     : 0x0
+CPU part        : 0xc07
+CPU revision    : 5
+
+processor       : 1
+model name      : ARMv7 Processor rev 5 (v7l)
+BogoMIPS        : 38.40
+Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
+CPU implementer : 0x41
+CPU architecture: 7
+CPU variant     : 0x0
+CPU part        : 0xc07
+CPU revision    : 5
+
+processor       : 2
+model name      : ARMv7 Processor rev 5 (v7l)
+BogoMIPS        : 38.40
+Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
+CPU implementer : 0x41
+CPU architecture: 7
+CPU variant     : 0x0
+CPU part        : 0xc07
+CPU revision    : 5
+
+processor       : 3
+model name      : ARMv7 Processor rev 5 (v7l)
+BogoMIPS        : 38.40
+Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
+CPU implementer : 0x41
+CPU architecture: 7
+CPU variant     : 0x0
+CPU part        : 0xc07
+CPU revision    : 5
+
+Hardware        : BCM2709
+Revision        : a01041
+Serial          : 00000000c9e9323d
diff --git a/tests/sysinfodata/arm-rpi2sysinfo.expect b/tests/sysinfodata/arm-rpi2sysinfo.expect
new file mode 100644 (file)
index 0000000..acb3ad9
--- /dev/null
@@ -0,0 +1,18 @@
+<sysinfo type='smbios'>
+  <processor>
+    <entry name='socket_destination'>0</entry>
+    <entry name='type'>ARMv7 Processor rev 5 (v7l)</entry>
+  </processor>
+  <processor>
+    <entry name='socket_destination'>1</entry>
+    <entry name='type'>ARMv7 Processor rev 5 (v7l)</entry>
+  </processor>
+  <processor>
+    <entry name='socket_destination'>2</entry>
+    <entry name='type'>ARMv7 Processor rev 5 (v7l)</entry>
+  </processor>
+  <processor>
+    <entry name='socket_destination'>3</entry>
+    <entry name='type'>ARMv7 Processor rev 5 (v7l)</entry>
+  </processor>
+</sysinfo>
index d8266a72aeddedaad4196a8032620e209eecf35f..74e5f71fc21a9402cc3742abfb83c0a19fad646e 100644 (file)
@@ -166,11 +166,23 @@ VIRT_TEST_MAIN(test_x86)
 static int
 test_arm(void)
 {
-    return sysinfotest_run("arm sysinfo",
-                           NULL,
-                           NULL,
-                           "/sysinfodata/armcpuinfo.data",
-                           "/sysinfodata/armsysinfo.expect");
+    int ret = EXIT_SUCCESS;
+
+    if (sysinfotest_run("arm sysinfo",
+                        NULL,
+                        NULL,
+                        "/sysinfodata/armcpuinfo.data",
+                        "/sysinfodata/armsysinfo.expect") != EXIT_SUCCESS)
+        ret = EXIT_FAILURE;
+
+    if (sysinfotest_run("Raspberry Pi 2 sysinfo",
+                        NULL,
+                        NULL,
+                        "/sysinfodata/arm-rpi2cpuinfo.data",
+                        "/sysinfodata/arm-rpi2sysinfo.expect") != EXIT_SUCCESS)
+        ret = EXIT_FAILURE;
+
+    return ret;
 }
 
 VIRT_TEST_MAIN(test_arm)