[libvirt] [PATCH 3/3] virSysinfoReadARM: Try reading DMI table

Michal Privoznik posted 3 patches 5 years, 6 months ago
There is a newer version of this series
[libvirt] [PATCH 3/3] virSysinfoReadARM: Try reading DMI table
Posted by Michal Privoznik 5 years, 6 months ago
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 <mprivozn@redhat.com>
---
 src/util/virsysinfo.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index 6c3adc23ab..783440314c 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -192,6 +192,14 @@ void virSysinfoDefFree(virSysinfoDefPtr def)
 }
 
 
+static bool
+virSysinfoDefEmpty(const virSysinfoDef *def)
+{
+    return !(def->bios || def->system || def->nbaseBoard ||
+             def->chassis || def->nprocessor || def->nmemory || def->oemStrings);
+}
+
+
 static int
 virSysinfoParsePPCSystem(const char *base, virSysinfoSystemDefPtr *sysdef)
 {
@@ -433,6 +441,16 @@ virSysinfoReadARM(void)
     virSysinfoDefPtr ret = NULL;
     char *outbuf = NULL;
 
+    /* Some ARM systems have DMI tables available. */
+    if ((ret = virSysinfoReadX86())) {
+        if (!virSysinfoDefEmpty(ret))
+            return ret;
+        virSysinfoDefFree(ret);
+    }
+
+    /* Well, we've tried. Fall back to parsing cpuinfo */
+    virResetLastError();
+
     if (VIR_ALLOC(ret) < 0)
         goto no_memory;
 
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/3] virSysinfoReadARM: Try reading DMI table
Posted by Peter Krempa 5 years, 6 months ago
On Fri, May 10, 2019 at 09:52:28 +0200, Michal Privoznik wrote:
> 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 <mprivozn@redhat.com>
> ---
>  src/util/virsysinfo.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
> index 6c3adc23ab..783440314c 100644
> --- a/src/util/virsysinfo.c
> +++ b/src/util/virsysinfo.c
> @@ -192,6 +192,14 @@ void virSysinfoDefFree(virSysinfoDefPtr def)
>  }
>  
>  
> +static bool
> +virSysinfoDefEmpty(const virSysinfoDef *def)
> +{
> +    return !(def->bios || def->system || def->nbaseBoard ||
> +             def->chassis || def->nprocessor || def->nmemory || def->oemStrings);
> +}
> +
> +
>  static int
>  virSysinfoParsePPCSystem(const char *base, virSysinfoSystemDefPtr *sysdef)
>  {
> @@ -433,6 +441,16 @@ virSysinfoReadARM(void)
>      virSysinfoDefPtr ret = NULL;
>      char *outbuf = NULL;
>  
> +    /* Some ARM systems have DMI tables available. */
> +    if ((ret = virSysinfoReadX86())) {

This is ultra fishy. If this function works on ARM it's time to rename
that function first.

> +        if (!virSysinfoDefEmpty(ret))
> +            return ret;
> +        virSysinfoDefFree(ret);
> +    }
> +
> +    /* Well, we've tried. Fall back to parsing cpuinfo */
> +    virResetLastError();
> +
>      if (VIR_ALLOC(ret) < 0)
>          goto no_memory;
>  
> -- 
> 2.21.0
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list