From ec6ce6363a78aaaf6e3aa4c0e2d683d7d0cce183 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 9 May 2019 16:10:37 +0200 Subject: [PATCH] virSysinfoReadARM: Try reading DMI table https://bugzilla.redhat.com/show_bug.cgi?id=1426162 Turns out, some aarch64 systems have SMBIOS info. That means we can use dmidecode to fetch some information. If that fails, fall back to the old behaviour. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/util/virsysinfo.c | 19 +++ .../aarch64-gigabytesysinfo.expect | 142 +++++++++++++++++- 2 files changed, 160 insertions(+), 1 deletion(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index b371e8dd26..5be5e5133d 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -192,6 +192,15 @@ void virSysinfoDefFree(virSysinfoDefPtr def) } +static bool +virSysinfoDefIsEmpty(const virSysinfoDef *def) +{ + return !(def->bios || def->system || def->nbaseBoard > 0 || + def->chassis || def->nprocessor > 0 || + def->nmemory > 0 || def->oemStrings); +} + + static int virSysinfoParsePPCSystem(const char *base, virSysinfoSystemDefPtr *sysdef) { @@ -433,6 +442,16 @@ virSysinfoReadARM(void) virSysinfoDefPtr ret = NULL; char *outbuf = NULL; + /* Some ARM systems have DMI tables available. */ + if ((ret = virSysinfoReadDMI())) { + if (!virSysinfoDefIsEmpty(ret)) + return ret; + virSysinfoDefFree(ret); + } + + /* Well, we've tried. Fall back to parsing cpuinfo */ + virResetLastError(); + if (VIR_ALLOC(ret) < 0) goto no_memory; diff --git a/tests/sysinfodata/aarch64-gigabytesysinfo.expect b/tests/sysinfodata/aarch64-gigabytesysinfo.expect index 73ea466bc3..a07dbc87dd 100644 --- a/tests/sysinfodata/aarch64-gigabytesysinfo.expect +++ b/tests/sysinfodata/aarch64-gigabytesysinfo.expect @@ -1 +1,141 @@ - + + + GIGABYTE + T49 + 02/02/2018 + 5.11 + + + GIGABYTE + R120-T34-00 + 0100 + 01234567890ABC + 01234567-89AB-CDEF-0123-4567890ABCDE + 01234567890123456789AB + Server + + + GIGABYTE + MT30-GS2-00 + 01234567 + 01234567890 + 01234567890123456789AB + Default string + + + GIGABYTE + 01234567 + 01234567890123456789AB + 01234567890123456789AB + SYS_CHASSIS_SKU_NUMBER_1 + + + Socket + Central Processor + ARM + CN8880-1800BG2601-CP-Y-G + Implementor 0x43, Variant 0x1, Architecture 15, Part 0x0a1, Revision 1 + 2.1 + 156 MHz + 1800 MHz + Populated, Enabled + CPU Serial# + CN88xx + + + 16384 MB + DIMM + DIMM_P0_A0 + P0_Node0_Channel0_Dimm0 + DDR4 + Registered (Buffered) + 2400 MT/s + Samsung + 01234567 + M393A2K40BB1-CRC + + + 16 GB + Unknown + DIMM_P0_A1 + P0_Node0_Channel0_Dimm1 + DDR4 + Unknown + Unknown + NO DIMM + NO DIMM + NO DIMM + + + 16384 MB + DIMM + DIMM_P0_B0 + P0_Node0_Channel1_Dimm0 + DDR4 + Registered (Buffered) + 2400 MT/s + Samsung + 3405E86E + M393A2K40BB1-CRC + + + 16 GB + Unknown + DIMM_P0_B1 + P0_Node0_Channel1_Dimm1 + DDR4 + Unknown + Unknown + NO DIMM + NO DIMM + NO DIMM + + + 16384 MB + DIMM + DIMM_P0_C0 + P0_Node0_Channel2_Dimm0 + DDR4 + Registered (Buffered) + 2400 MT/s + Samsung + 01234567 + M393A2K40BB1-CRC + + + 16 GB + Unknown + DIMM_P0_C1 + P0_Node0_Channel2_Dimm1 + DDR4 + Unknown + Unknown + NO DIMM + NO DIMM + NO DIMM + + + 16384 MB + DIMM + DIMM_P0_D0 + P0_Node0_Channel3_Dimm0 + DDR4 + Registered (Buffered) + 2400 MT/s + Samsung + 01234567 + M393A2K40BB1-CRC + + + 16 GB + Unknown + DIMM_P0_D1 + P0_Node0_Channel3_Dimm1 + DDR4 + Unknown + Unknown + NO DIMM + NO DIMM + NO DIMM + +