mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
virsysinfo: Be more forgiving when decoding OEM strings
On some systems, there are two or even more 'OEM Strings' sections in DMI table. Here's an example of dmidecode output on such system: # dmidecode -q -t 11 OEM Strings String 1: Default string OEM Strings String 1: ThunderX2 System String 2: cavium.com String 3: Comanche Now, this poses a problem, because when one tries to obtain individual strings, they get: # dmidecode -q --oem-string 1 Default string ThunderX2 System # dmidecode -q --oem-string 2 No OEM string number 2 cavium.com NB, the "No OEM string number 2" is printed onto stderr and everything else onto stdout. Oh, and trying to get OEM strings from just one section doesn't fly: # dmidecode -q -H 0x1d --oem-string 2 Options --string, --type, --handle and --dump-bin are mutually exclusive This means two things: 1) we have no way of distinguishing OEM strings at the same index but in different sections, 2) because of how virSysinfoDMIDecodeOEMString() is written, we fail in querying OEM string that exists in one section but not in the others (for instance string #2 from example above). While there's not much we can do about 1), there is something that can be done about 2) - refine the error condition and make the function return an error iff there's nothing on stdout and there's something on stderr. Resolves: https://issues.redhat.com/browse/RHEL-45952 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
98a9dc532d
commit
5bb4540dbb
@ -910,9 +910,19 @@ virSysinfoDMIDecodeOEMString(size_t i,
|
||||
|
||||
/* Unfortunately, dmidecode returns 0 even if OEM String index is out
|
||||
* of bounds, but it prints an error message in that case. Check stderr
|
||||
* and return success/failure accordingly. */
|
||||
|
||||
if (err && *err != '\0')
|
||||
* and return success/failure accordingly.
|
||||
* To make matters worse, if there are two or more 'OEM String'
|
||||
* sections then:
|
||||
*
|
||||
* a) we have no way of distinguishing them as dmidecode prints
|
||||
* strings from all sections,
|
||||
* b) if one section contains a valid string, but the other doesn't,
|
||||
* then stdout contains the valid string and stderr contains the
|
||||
* error "No OEM string number X*.
|
||||
*
|
||||
* Let's just hope there is not many systems like that.
|
||||
*/
|
||||
if ((!*str || **str == '\0') && err && *err != '\0')
|
||||
return -1;
|
||||
|
||||
virStringTrimOptionalNewline(*str);
|
||||
|
Loading…
Reference in New Issue
Block a user