
On 6/2/20 12:56 PM, Daniel P. Berrangé wrote:
On Tue, Jun 02, 2020 at 12:53:18PM +0200, Michal Privoznik wrote:
Setting OEM strings for a domain was introduced in v4.1.0-rc1~315. However, any application that wanted to use them (e.g. to point to an URL where a config file is stored) had to 'dmidecode -u --oem-string N' (where N is index of the string). Well, we can expose them under our <sysinfo/> XML and if the domain is running Libvirt inside it can be obtained using virConnectGetSysinfo() API.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virsysinfo.c | 60 ++++++++++++++++++++++++++++- tests/sysinfodata/x86sysinfo.data | 10 +++++ tests/sysinfodata/x86sysinfo.expect | 10 +++++ 3 files changed, 79 insertions(+), 1 deletion(-)
diff --git a/tests/sysinfodata/x86sysinfo.data b/tests/sysinfodata/x86sysinfo.data index 426261041d..5615e144fb 100644 --- a/tests/sysinfodata/x86sysinfo.data +++ b/tests/sysinfodata/x86sysinfo.data @@ -81,3 +81,13 @@ Memory Device Serial Number: 29057112 Asset Tag: 0839 Part Number: IMSH2GS13A1F1C-10F + +OEM Strings + String 1: Default string + String 2: Default string + String 3: MIAMI + String 4: Default string + String 5: FFFFFFFFFFFFF + String 6: FFFFFFFFFFFFF + String 7: FFFFFFFFFFFFF + String 8: Default string
What does dmidecode do for escaping (if anything) if I set a string value of
"Ha ha ha try parsing\n String 3: this correctly\n String 4:then"
This is what I put into domain XML: <sysinfo type='smbios'> <oemStrings> <entry>Hello</entry> <entry>World</entry> <entry>Ha ha ha try parsing\n String 3: this correctly\n String 4:then</entry> <entry>This is, more tricky value=escaped</entry> </oemStrings> </sysinfo> This is how it appeared on the cmd line: -smbios 'type=11,value=Hello,value=World,value=Ha ha ha try parsing\n String 3: this correctly\n String 4:then,value=This is,, more tricky value=escaped' \ Now, inside the guest, plain dmidecode replaces \n with a dot: # dmidecode -t 11 Handle 0x0E00, DMI type 11, 5 bytes OEM Strings String 1: Hello String 2: World String 3: Ha ha ha try parsing\n. String 3: this correctly\n. String 4:then String 4: This is, more tricky value=escaped But if I tell it to not decode entries, then it displays the string correctly: # dmidecode -u --oem-string 3 Ha ha ha try parsing\n String 3: this correctly\n String 4:then So maybe we should use the latter instead? We could use 'dmidecode -u --oem-string count' to get the number of strings and then iterate through each one of them. Michal