libxl smbios support
cover libxl smbios support
hvm_xs_strings.h specifies xenstore entries which can be used to set or override smbios strings. hvmloader has support for reading them, but xl/libxl support is not wired up. This patches adds a new xl.cfg option and libxl support to write the xenstore strings.
The xl syntax looks like:
smbios=["bios_vendor=Xen Project","system_version=1.0"]
The Go binding generation needed extending to support Arrays inside a KeyedUnion, which is what the first patch does. The generated go code builds, but it is otherwise untested.
There are also oem strings, oem-1..oem-99, that HVM loader supports. The use of smbios_type Enum is a little unwieldy to defined so many entries, but it works. xl will internally parse smbios=["oem=A,oem=B"] into oem_1 = "A" and oem_2 = "B". xl still accepts oem_$N, though hvmloader only reads sequentially from 1 up to a maximum of 99. It's a corner case what doesn't seem worth dealing with.
The rendered man page and html don't have a newline at then end of the new section after patch 2.
"""
battery_device_name=STRING
ms_vm_genid="OPTION"
"""
however the txt format is correct:
"""
battery_device_name=STRING
ms_vm_genid="OPTION"
"""
It goes away after patch 3 is applied since it adds text about the "oem" option in between the two lines above. I'm at a loss as to why this is happening.
Jason Andryuk (3):
golang/xenlight: Extend KeyedUnion to support Arrays xl/libxl: Add ability to specify SMBIOS strings xl/libxl: Add OEM string support to smbios
docs/man/xl.cfg.5.pod.in | 49 +++++++++++ tools/golang/xenlight/gengotypes.py | 41 +++++---- tools/golang/xenlight/helpers.gen.go | 51 +++++++++++ tools/golang/xenlight/types.gen.go | 126 +++++++++++++++++++++++++++ tools/include/libxl.h | 5 ++ tools/libs/light/libxl_dom.c | 20 +++++ tools/libs/light/libxl_types.idl | 125 ++++++++++++++++++++++++++ tools/xl/xl_parse.c | 59 ++++++++++++- 8 files changed, 459 insertions(+), 17 deletions(-)
Signature · 1 line
2.37.1
PATCH 1/3 golang/xenlight: Extend KeyedUnion to support Arrays
Generation for KeyedUnion types doesn't support Arrays. The smbios support will place an smbios array inside the hvm KeyedUnion, and gentotypes doesn't generate buildable Go code.
Have KeyedUnion add an idl.Array check and issue the approriate xenlight_golang_array_to_C and xenlight_golang_array_from_C calls when needed. This matches how it is done in xenlight_golang_define_to_C & xenlight_golang_define_from_C
xenlight_golang_array_to_C and xenlight_golang_array_from_C need to be extended to set the cvarname and govarname as approriate for the KeyedUnion cases to match the surrounding code.
--- tools/golang/xenlight/gengotypes.py | 41 ++++++++++++++++++----------- 1 file changed, 25 insertions(+), 16 deletions(-)
tools/golang/xenlight/gengotypes.py +25 -16
@@ -374,6 +374,10 @@ def xenlight_golang_union_from_C(ty = None, union_name = '', struct_name = ''): s += 'tmp := (*C.{0})(unsafe.Pointer(&xc.{1}[0]))\n'.format(typename,union_name) for nf in f.type.fields: + if isinstance(nf.type, idl.Array): + s += xenlight_golang_array_from_C(nf,cvarname='tmp') + continue + s += xenlight_golang_convert_from_C(nf,cvarname='tmp') s += 'return nil\n'
@@ -414,7 +418,7 @@ def xenlight_golang_union_from_C(ty = None, union_name = '', struct_name = ''): return (s,extras) -def xenlight_golang_array_from_C(ty = None): +def xenlight_golang_array_from_C(ty = None, cvarname = 'xc'): """ Convert C array to Go slice using the method described here:
@@ -431,9 +435,9 @@ def xenlight_golang_array_from_C(ty = None): clenvar = ty.type.lenvar.name s += 'x.{0} = nil\n'.format(goname) - s += 'if n := int(xc.{0}); n > 0 {{\n'.format(clenvar) + s += 'if n := int({0}.{1}); n > 0 {{\n'.format(cvarname,clenvar) s += '{0} := '.format(cslice) - s +='(*[1<<28]C.{0})(unsafe.Pointer(xc.{1}))[:n:n]\n'.format(ctypename, cname) + s +='(*[1<<28]C.{0})(unsafe.Pointer({1}.{2}))[:n:n]\n'.format(ctypename, cvarname, cname) s += 'x.{0} = make([]{1}, n)\n'.format(goname, gotypename) s += 'for i, v := range {0} {{\n'.format(cslice)
@@ -577,6 +581,11 @@ def xenlight_golang_union_to_C(ty = None, union_name = '', s += 'var {0} C.{1}\n'.format(f.name,cgotype) for uf in f.type.fields: + if isinstance(uf.type, idl.Array): + s += xenlight_golang_array_to_C(uf, cvarname=f.name, + govarname="tmp") + continue + s += xenlight_golang_convert_to_C(uf,cvarname=f.name, govarname='tmp')
@@ -594,7 +603,7 @@ def xenlight_golang_union_to_C(ty = None, union_name = '', return s -def xenlight_golang_array_to_C(ty = None): +def xenlight_golang_array_to_C(ty = None, cvarname="xc", govarname="x"): s = '' gotypename = xenlight_golang_fmt_name(ty.type.elem_type.typename)
@@ -606,27 +615,27 @@ def xenlight_golang_array_to_C(ty = None): is_enum = isinstance(ty.type.elem_type,idl.Enumeration) if gotypename in go_builtin_types or is_enum: - s += 'if {0} := len(x.{1}); {2} > 0 {{\n'.format(golenvar,goname,golenvar) - s += 'xc.{0} = (*C.{1})(C.malloc(C.size_t({2}*{3})))\n'.format(cname,ctypename, + s += 'if {0} := len({1}.{2}); {3} > 0 {{\n'.format(golenvar,govarname,goname,golenvar) + s += '{0}.{1} = (*C.{2})(C.malloc(C.size_t({3}*{4})))\n'.format(cvarname,cname,ctypename, golenvar,golenvar) - s += 'xc.{0} = C.int({1})\n'.format(clenvar,golenvar) - s += 'c{0} := (*[1<<28]C.{1})(unsafe.Pointer(xc.{2}))[:{3}:{4}]\n'.format(goname, - ctypename,cname, + s += '{0}.{1} = C.int({2})\n'.format(cvarname,clenvar,golenvar) + s += 'c{0} := (*[1<<28]C.{1})(unsafe.Pointer({2}.{3}))[:{4}:{5}]\n'.format(goname, + ctypename,cvarname,cname, golenvar,golenvar) - s += 'for i,v := range x.{0} {{\n'.format(goname) + s += 'for i,v := range {0}.{1} {{\n'.format(govarname,goname) s += 'c{0}[i] = C.{1}(v)\n'.format(goname,ctypename) s += '}\n}\n' return s - s += 'if {0} := len(x.{1}); {2} > 0 {{\n'.format(golenvar,goname,golenvar) - s += 'xc.{0} = (*C.{1})(C.malloc(C.ulong({2})*C.sizeof_{3}))\n'.format(cname,ctypename, + s += 'if {0} := len({1}.{2}); {3} > 0 {{\n'.format(golenvar,govarname,goname,golenvar) + s += '{0}.{1} = (*C.{2})(C.malloc(C.ulong({3})*C.sizeof_{4}))\n'.format(cvarname,cname,ctypename, golenvar,ctypename) - s += 'xc.{0} = C.int({1})\n'.format(clenvar,golenvar) - s += 'c{0} := (*[1<<28]C.{1})(unsafe.Pointer(xc.{2}))[:{3}:{4}]\n'.format(goname, - ctypename,cname, + s += '{0}.{1} = C.int({2})\n'.format(cvarname,clenvar,golenvar) + s += 'c{0} := (*[1<<28]C.{1})(unsafe.Pointer({2}.{3}))[:{4}:{5}]\n'.format(goname, + ctypename,cvarname,cname, golenvar,golenvar) - s += 'for i,v := range x.{0} {{\n'.format(goname) + s += 'for i,v := range {0}.{1} {{\n'.format(govarname,goname) s += 'if err := v.toC(&c{0}[i]); err != nil {{\n'.format(goname) s += 'return fmt.Errorf("converting field {0}: %v", err)\n'.format(goname) s += '}\n}\n}\n'
Signature · 1 line
2.37.1
PATCH 2/3 xl/libxl: Add ability to specify SMBIOS strings
In reply to Jason Andryukhvm_xs_strings.h specifies xenstore entries which can be used to set or override smbios strings. hvmloader has support for reading them, but xl/libxl support is not wired up.
Allow specifying the strings with the new xl.cfg option:
smbios=["bios_vendor=Xen Project","system_version=1.0"]
In terms of strings, the SMBIOS specification 3.5 says:
https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.5.0.pdf
"""
Strings must be encoded as UTF-8 with no byte order mark (BOM). For compatibility with older SMBIOS parsers, US-ASCII characters should be used. NOTE There is no limit on the length of each individual text string. However, the length of the entire structure table (including all strings) must be reported in the Structure Table Length field of the 32-bit Structure Table Entry Point (see 5.2.1) and/or the Structure Table Maximum Size field of the 64-bit Structure Table Entry Point (see 5.2.2).
"""
The strings aren't checked for utf-8 or length. hvmloader has a sanity check on the overall length.
The libxl_smbios_type enum starts at 1 since otherwise the 0th key is not printed in the json output.
---
The rendered man page and html don't have a newline at then end of the new section.
"""
battery_device_name=STRING
ms_vm_genid="OPTION"
"""
however the txt format is correct:
"""
battery_device_name=STRING
ms_vm_genid="OPTION"
"""
I'm at a loss as to why this is happening.
--- docs/man/xl.cfg.5.pod.in | 45 ++++++++++++++++++++++++ tools/golang/xenlight/helpers.gen.go | 51 ++++++++++++++++++++++++++++ tools/golang/xenlight/types.gen.go | 27 +++++++++++++++ tools/include/libxl.h | 5 +++ tools/libs/light/libxl_dom.c | 20 +++++++++++ tools/libs/light/libxl_types.idl | 26 ++++++++++++++ tools/xl/xl_parse.c | 44 +++++++++++++++++++++++- 7 files changed, 217 insertions(+), 1 deletion(-)
docs/man/xl.cfg.5.pod.in +45 -0
@@ -2061,6 +2061,51 @@ number of vendor defined SMBIOS structures (type 128 - 255). Since SMBIOS structures do not present their overall size, each entry in the file must be preceded by a 32b integer indicating the size of the following structure. +=item B<smbios=[ "SMBIOS_SPEC_STRING", "SMBIOS_SPEC_STRING", ...]> + +Specifies the SMBIOS values to be provided to the guest. These set or +override specific entries in the tables provided to the guest. + +Each B<SMBIOS_SPEC_STRING> is a C<KEY=VALUE> string from the following list: + +=over 4 + +=item B<bios_vendor=STRING> + +=item B<bios_version=STRING> + +=item B<system_manufacturer=STRING> + +=item B<system_product_name=STRING> + +=item B<system_version=STRING> + +=item B<system_serial_number=STRING> + +=item B<baseboard_manufacturer=STRING> + +=item B<baseboard_product_name=STRING> + +=item B<baseboard_version=STRING> + +=item B<baseboard_serial_number=STRING> + +=item B<baseboard_asset_tag=STRING> + +=item B<baseboard_location_in_chassis=STRING> + +=item B<enclosure_manufacturer=STRING> + +=item B<enclosure_serial_number=STRING> + +=item B<enclosure_asset_tag=STRING> + +=item B<battery_manufacturer=STRING> + +=item B<battery_device_name=STRING> + +=back + =item B<ms_vm_genid="OPTION"> Provide a VM generation ID to the guest.
tools/golang/xenlight/helpers.gen.go +51 -0
69 lines not on this page · raw message
tools/golang/xenlight/types.gen.go +27 -0
@@ -386,6 +386,32 @@ Commandline string BuildId string } +type SmbiosType int +const( +SmbiosTypeBiosVendor SmbiosType = 1 +SmbiosTypeBiosVersion SmbiosType = 2 +SmbiosTypeSystemManufacturer SmbiosType = 3 +SmbiosTypeSystemProductName SmbiosType = 4 +SmbiosTypeSystemVersion SmbiosType = 5 +SmbiosTypeSystemSerialNumber SmbiosType = 6 +SmbiosTypeBaseboardManufacturer SmbiosType = 7 +SmbiosTypeBaseboardProductName SmbiosType = 8 +SmbiosTypeBaseboardVersion SmbiosType = 9 +SmbiosTypeBaseboardSerialNumber SmbiosType = 10 +SmbiosTypeBaseboardAssetTag SmbiosType = 11 +SmbiosTypeBaseboardLocationInChassis SmbiosType = 12 +SmbiosTypeEnclosureManufacturer SmbiosType = 13 +SmbiosTypeEnclosureSerialNumber SmbiosType = 14 +SmbiosTypeEnclosureAssetTag SmbiosType = 15 +SmbiosTypeBatteryManufacturer SmbiosType = 16 +SmbiosTypeBatteryDeviceName SmbiosType = 17 +) + +type Smbios struct { +Key SmbiosType +Value string +} + type DomainCreateInfo struct { Type DomainType Hap Defbool
@@ -568,6 +594,7 @@ NestedHvm Defbool Altp2M Defbool SystemFirmware string SmbiosFirmware string +Smbios []Smbios AcpiFirmware string Hdtype Hdtype Nographic Defbool
tools/include/libxl.h +5 -0
@@ -174,6 +174,11 @@*/ #define LIBXL_HAVE_BUILDINFO_HVM_MS_VM_GENID 1 +/* +* libxl_domain_build_info has the u.hvm.smbios field. +*/ +#define LIBXL_HAVE_BUILDINFO_HVM_SMBIOS 1 +/* * LIBXL_HAVE_VCPUINFO_SOFT_AFFINITY indicates that a 'cpumap_soft' * field (of libxl_bitmap type) is present in libxl_vcpuinfo,
tools/libs/light/libxl_dom.c +20 -0
@@ -771,6 +771,26 @@ static int hvm_build_set_xs_values(libxl__gc *gc, goto err; } +for (int i =0 ; i < info->u.hvm.num_smbios; i++) { +char *p; + path =GCSPRINTF ("/local/domain/%d/" HVM_XS_BIOS_STRINGS "/%s" , domid, +libxl_smbios_type_to_string (info->u.hvm.smbios[i].key)); + +/* libxl defines are all "_", but the HVM_XS_ strings are "-". */ + p =strrchr (path,'/' ); +for ( ; *p; p++) { +if (*p =='_' ) + *p ='-' ; + } + +LOGD (DEBUG , domid,"Writing %d %s %s\n" , i, path, + info->u.hvm.smbios[i].value); + ret =libxl__xs_printf (gc,XBT_NULL , path,"%s" , + info->u.hvm.smbios[i].value); +if (ret) + goto err; + } +/* Only one module can be passed. PVHv2 guests do not support this. */ if (dom->acpi_modules[0 ].guest_addr_out && info->type ==LIBXL_DOMAIN_TYPE_HVM ) {
tools/libs/light/libxl_types.idl +26 -0
@@ -418,6 +418,31 @@ libxl_version_info = Struct("version_info", [ ("build_id", string), ], dir=DIR_OUT) +libxl_smbios_type = Enumeration("smbios_type", [ + (1, "bios_vendor"), + (2, "bios_version"), + (3, "system_manufacturer"), + (4, "system_product_name"), + (5, "system_version"), + (6, "system_serial_number"), + (7, "baseboard_manufacturer"), + (8, "baseboard_product_name"), + (9, "baseboard_version"), + (10, "baseboard_serial_number"), + (11, "baseboard_asset_tag"), + (12, "baseboard_location_in_chassis"), + (13, "enclosure_manufacturer"), + (14, "enclosure_serial_number"), + (15, "enclosure_asset_tag"), + (16, "battery_manufacturer"), + (17, "battery_device_name"), + ]) + +libxl_smbios = Struct("smbios", [ + ("key", libxl_smbios_type), + ("value", string), + ], dir=DIR_IN) + libxl_domain_create_info = Struct("domain_create_info",[ ("type", libxl_domain_type), ("hap", libxl_defbool),
@@ -604,6 +629,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("altp2m", libxl_defbool), ("system_firmware", string), ("smbios_firmware", string), + ("smbios", Array(libxl_smbios, "num_smbios")), ("acpi_firmware", string), ("hdtype", libxl_hdtype), ("nographic", libxl_defbool),
tools/xl/xl_parse.c +43 -1
57 lines not on this page · raw message
Signature · 1 line
2.37.1
Re: [PATCH 2/3] xl/libxl: Add ability to specify SMBIOS strings
Quoted 35 lines · Jason Andryuk
hvm_xs_strings.hspecifies xenstore entries which can be used to set or override smbios strings. hvmloader has support for reading them, but xl/libxl support is not wired up.Allow specifying the strings with the new xl.cfg option:
smbios=["bios_vendor=Xen Project","system_version=1.0"]In terms of strings, the SMBIOS specification 3.5 says:
https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.5.0.pdf
"""
Strings must be encoded as UTF-8 with no byte order mark (BOM). For compatibility with older SMBIOS parsers, US-ASCII characters should be used. NOTE There is no limit on the length of each individual text string. However, the length of the entire structure table (including all strings) must be reported in the Structure Table Length field of the 32-bit Structure Table Entry Point (see 5.2.1) and/or the Structure Table Maximum Size field of the 64-bit Structure Table Entry Point (see 5.2.2).
"""The strings aren't checked for utf-8 or length. hvmloader has a sanity check on the overall length.
The
libxl_smbios_typeenum starts at 1 since otherwise the 0th key is not printed in the json output.Signed-off-by Jason Andryuk <[email protected]>---
The rendered man page and html don't have a newline at then end of the new section.
"""
battery_device_name=STRING
ms_vm_genid="OPTION"
"""
Quoted 8 lines
however the txt format is correct:
"""
battery_device_name=STRINGms_vm_genid="OPTION"
"""I'm at a loss as to why this is happening.
Maybe it's because =back just cancel =over, and pod2man just keeps going as if it's the same list. Adding some text for the =item or after =back would help, but that's done in the next patch, so I guess we can live with that for one commit.
Quoted 6 lines
---
tools/libs/light/libxl_dom.c +0
-0
tools/libs/light/libxl_dom.c static int hvm_build_set_xs_values(libxl__gc *gc, · line 779
Quoted 9 lines
tools/libs/light/libxl_dom.c +6
-0@@ -771,6 +771,26 @@ static int hvm_build_set_xs_values(libxl__gc *gc, goto err; } +for (int i =0 ; i < info->u.hvm.num_smbios; i++) { +char *p; + path =GCSPRINTF ("/local/domain/%d/" HVM_XS_BIOS_STRINGS "/%s" , domid, +libxl_smbios_type_to_string (info->u.hvm.smbios[i].key)); + +/* libxl defines are all "_", but the HVM_XS_ strings are "-". */
"libxl defines are all "_"" seems a bit weird to me as a comment in the source code, maybe a better comment would the conversion we need to do, something like:
Convert libxl_smbios_type string to xenstore path that hvmloader will use, as defined by HVM_XS_*. That is convert the '_' to '-'.
tools/libs/light/libxl_dom.c static int hvm_build_set_xs_values(libxl__gc *gc, · line 786
Quoted 7 lines
tools/libs/light/libxl_dom.c +7
-0+ p =strrchr (path,'/' ); +for ( ; *p; p++) { +if (*p =='_' ) + *p ='-' ; + } + + LOGD(DEBUG, domid, "Writing %d %s %s\n", i, path,
I don't think printing the value of i would be useful here. Also adding a '=' before the value and putting the value between double-quote would be a bit better.
Quoted 31 lines
tools/libs/light/libxl_dom.c +7
-0+ info->u.hvm.smbios[i].value); + ret =libxl__xs_printf (gc,XBT_NULL , path,"%s" , + info->u.hvm.smbios[i].value); +if (ret) + goto err; + } +/* Only one module can be passed. PVHv2 guests do not support this. */ if (dom->acpi_modules[0 ].guest_addr_out && info->type ==LIBXL_DOMAIN_TYPE_HVM ) {tools/xl/xl_parse.c +4
-1@@ -1220,8 +1220,9 @@ void parse_config_data(const char *config_source,XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms, *usbctrls, *usbdevs, *p9devs, *vdispls, *pvcallsifs_devs;XLU_ConfigList *channels, *ioports, *irqs, *iomem, *viridian, *dtdevs, - *mca_caps; + *mca_caps, *smbios;int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian, num_mca_caps; +int num_smbios;int pci_power_mgmt =0 ;int pci_msitranslate =0 ;int pci_permissive =0 ;@@ -1783,6 +1784,47 @@ void parse_config_data(const char *config_source,xlu_cfg_replace_string (config,"acpi_firmware" , &b_info->u.hvm.acpi_firmware,0 ); +switch (xlu_cfg_get_list (config,"smbios" , &smbios, &num_smbios,0 )) + {
tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1798
Quoted 10 lines
tools/xl/xl_parse.c +10
-0+case 0 :/* Success */ + b_info->u.hvm.num_smbios = num_smbios; + b_info->u.hvm.smbios =xcalloc (num_smbios,sizeof (libxl_smbios)); +for (i =0 ; i < num_smbios; i++) { +char *option_untrimmed, *value_untrimmed; +char *option, *value; +libxl_smbios_type v; + + buf =xlu_cfg_get_listitem (smbios, i); +if (!buf)continue ;
Isn't this an error? It seems that xlu_cfg_get_listitem would return 0 if 'i' is outside of the array or if the value isn't a string. I think it would also mean that "smbios[i].key" and ".value" would have uninitialized value and potentially garbage.
tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1808
Quoted 10 lines
tools/xl/xl_parse.c +10
-0+ +if (split_string_into_pair (buf,"=" , + &option_untrimmed, + &value_untrimmed)) { +fprintf (stderr,"xl: failed to split \"%s\" into pair\n" , + buf); +exit (EXIT_FAILURE ); + } +trim (isspace, option_untrimmed, &option); +trim (isspace, value_untrimmed, &value);
I think you could free "option_untrimmed" and "value_untrimmed", as "option" and "value" are newly allocated strings. Also, "option" won't be needed after it's been converted to an enum value.
Quoted 4 lines
tools/xl/xl_parse.c +4
-0+ + e =libxl_smbios_type_from_string (option, &v); +if (e) { + fprintf(stderr,
tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1822
Quoted 10 lines
tools/xl/xl_parse.c +10
-0+"xl: unknown smbios type '%s'\n" , + buf); +exit (-ERROR_FAIL ); + } + + b_info->u.hvm.smbios[i].key = v; + b_info->u.hvm.smbios[i].value = value; + } +break ; +case ESRCH :break ;/* Option not present */
Could you move the "break" to a new line? It will make it easier to read that ESRCH is just ignore instead of throwing an error.
tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1830
Quoted 8 lines
tools/xl/xl_parse.c +5
-0+default : +fprintf (stderr,"xl: Unable to parse smbios options.\n" ); +exit (-ERROR_FAIL ); + } +if (!xlu_cfg_get_string (config,"ms_vm_genid" , &buf,0 )) {if (!strcmp (buf,"generate" )) { e =libxl_ms_vm_genid_generate (ctx, &b_info->u.hvm.ms_vm_genid);
Thanks,
Signature · 1 line
Anthony PERARD
Re: [PATCH 2/3] xl/libxl: Add ability to specify SMBIOS strings
Quoted 20 lines · Anthony PERARD
Quoted 6 lines
---
tools/libs/light/libxl_dom.c +0
-0tools/libs/light/libxl_dom.c static int hvm_build_set_xs_values(libxl__gc *gc, · line 779
Quoted 9 lines
tools/libs/light/libxl_dom.c +6
-0@@ -771,6 +771,26 @@ static int hvm_build_set_xs_values(libxl__gc *gc, goto err; } +for (int i =0 ; i < info->u.hvm.num_smbios; i++) { +char *p; + path =GCSPRINTF ("/local/domain/%d/" HVM_XS_BIOS_STRINGS "/%s" , domid, +libxl_smbios_type_to_string (info->u.hvm.smbios[i].key)); + +/* libxl defines are all "_", but the HVM_XS_ strings are "-". */ "libxl defines are all "_"" seems a bit weird to me as a comment in the source code, maybe a better comment would the conversion we need to do, something like:
Quoted 2 lines
Convert
libxl_smbios_typestring to xenstore path that hvmloader will use, as defined by HVM_XS_*. That is convert the '_' to '-'.
I'll use this. All your other comments sound good, and I'll change accordingly.
Thanks for taking a look.
-Jason
PATCH 3/3 xl/libxl: Add OEM string support to smbios
In reply to Jason AndryukAdd support for OEM strings in the SMBIOS type 11.
hvmloader checks them sequentially, so hide the implementation detail. Allow multiple plain oem= items and assign the numeric values internally.
---
This change re-introduces the newline before ms_vm_genid.
--- docs/man/xl.cfg.5.pod.in | 4 ++ tools/golang/xenlight/types.gen.go | 99 ++++++++++++++++++++++++++++++ tools/libs/light/libxl_types.idl | 99 ++++++++++++++++++++++++++++++ tools/xl/xl_parse.c | 15 +++++ 4 files changed, 217 insertions(+)
docs/man/xl.cfg.5.pod.in +4 -0
@@ -2104,8 +2104,12 @@ Each B<SMBIOS_SPEC_STRING> is a C<KEY=VALUE> string from the following list: =item B<battery_device_name=STRING> +=item B<oem=STRING> + =back +oem= strings can be specified mutiple times up to a limit of 99. + =item B<ms_vm_genid="OPTION"> Provide a VM generation ID to the guest.
tools/golang/xenlight/types.gen.go +99 -0
105 lines not on this page · raw message
tools/libs/light/libxl_types.idl +99 -0
105 lines not on this page · raw message
tools/xl/xl_parse.c +15 -0
@@ -1787,12 +1787,16 @@ void parse_config_data(const char *config_source,switch (xlu_cfg_get_list (config,"smbios" , &smbios, &num_smbios,0 )) {case 0 :/* Success */ + { +unsigned int num_oem =1 ; + b_info->u.hvm.num_smbios = num_smbios; b_info->u.hvm.smbios =xcalloc (num_smbios,sizeof (libxl_smbios));for (i =0 ; i < num_smbios; i++) {char *option_untrimmed, *value_untrimmed;char *option, *value;libxl_smbios_type v; +char oem_buf[] ="oem_99" ; buf =xlu_cfg_get_listitem (smbios, i);if (!buf)continue ;
@@ -1807,6 +1811,16 @@ void parse_config_data(const char *config_source,trim (isspace, option_untrimmed, &option);trim (isspace, value_untrimmed, &value); +if (strcmp (option,"oem" ) ==0 ) { +if (num_oem >99 ) { +fprintf (stderr,"xl: sbmios oem strings limited to 99\n" ); +exit (-ERROR_FAIL ); + } +sprintf (oem_buf,"oem_%d" , num_oem); + num_oem++; + option = oem_buf; + } + e =libxl_smbios_type_from_string (option, &v);if (e) { fprintf(stderr,
@@ -1819,6 +1833,7 @@ void parse_config_data(const char *config_source, b_info->u.hvm.smbios[i].value = value; }break ; + }case ESRCH :break ;/* Option not present */ default :fprintf (stderr,"xl: Unable to parse smbios options.\n" );
Signature · 1 line
2.37.1
Re: [PATCH 3/3] xl/libxl: Add OEM string support to smbios
Quoted 19 lines · Jason Andryuk
Add support for OEM strings in the SMBIOS type 11.
hvmloader checks them sequentially, so hide the implementation detail. Allow multiple plain oem= items and assign the numeric values internally.
Signed-off-by Jason Andryuk <[email protected]>--- docs/man/xl.cfg.5.pod.in | 4 ++ tools/golang/xenlight/types.gen.go | 99 ++++++++++++++++++++++++++++++ tools/libs/light/libxl_types.idl | 99 ++++++++++++++++++++++++++++++ tools/xl/xl_parse.c | 15 +++++ 4 files changed, 217 insertions(+)docs/man/xl.cfg.5.pod.in +0
-0
docs/man/xl.cfg.5.pod.in Each B<SMBIOS_SPEC_STRING> is a C<KEY=VALUE> string from the following list: · line 2111
Quoted 8 lines
docs/man/xl.cfg.5.pod.in +3
-0@@ -2104,8 +2104,12 @@ Each B<SMBIOS_SPEC_STRING> is a C<KEY=VALUE> string from the following list: =item B<battery_device_name=STRING> +=item B<oem=STRING> + =back +oem= strings can be specified mutiple times up to a limit of 99.
This could be move to just before =back I think.
Quoted 15 lines
docs/man/xl.cfg.5.pod.in +1
-0+ =item B<ms_vm_genid="OPTION"> Provide a VM generation ID to the guest.tools/libs/light/libxl_types.idl +3
-0@@ -436,6 +436,105 @@ libxl_smbios_type = Enumeration("smbios_type", [ (15, "enclosure_asset_tag"), (16, "battery_manufacturer"), (17, "battery_device_name"), + (18, "oem_1"), + (19, "oem_2"), + (20, "oem_3"),
[...]
tools/libs/light/libxl_types.idl libxl_smbios_type = Enumeration("smbios_type", [ · line 537
Quoted 2 lines
tools/libs/light/libxl_types.idl +2
-0+ (115, "oem_98"), + (116, "oem_99"),
Instead of this long lists of enum value, could we just have one "oem" type, and allow it to be used more than once? I know that would mean having a special case in libxl, but that also mean that libxl will be the only one to deal with the implementation detail on how to write oem string for hvmloader (as opposed to deal with this in every application using libxl).
Quoted 26 lines
])
libxl_smbios= Struct("smbios", [tools/xl/xl_parse.c +4
-0@@ -1787,12 +1787,16 @@ void parse_config_data(const char *config_source,switch (xlu_cfg_get_list (config,"smbios" , &smbios, &num_smbios,0 )) {case 0 :/* Success */ + { +unsigned int num_oem =1 ; + b_info->u.hvm.num_smbios = num_smbios; b_info->u.hvm.smbios =xcalloc (num_smbios,sizeof (libxl_smbios));for (i =0 ; i < num_smbios; i++) {char *option_untrimmed, *value_untrimmed;char *option, *value;libxl_smbios_type v; +char oem_buf[] ="oem_99" ; buf =xlu_cfg_get_listitem (smbios, i);if (!buf)continue ;@@ -1807,6 +1811,16 @@ void parse_config_data(const char *config_source,trim (isspace, option_untrimmed, &option);
tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1821
Quoted 10 lines
tools/xl/xl_parse.c +8
-0trim (isspace, value_untrimmed, &value); +if (strcmp (option,"oem" ) ==0 ) { +if (num_oem >99 ) { +fprintf (stderr,"xl: sbmios oem strings limited to 99\n" ); +exit (-ERROR_FAIL ); + } +sprintf (oem_buf,"oem_%d" , num_oem); + num_oem++; + option = oem_buf;
This mean that my proposal to free option in the previous patch isn't going to work well. But you could free option before assigning a new value.
An alternative to generate a string to be converted to an enum value would be to simply do "LIBXL_SMBIOS_TYPE_OEM_1+num_oem-1". Or just deal with oem string in libxl as proposed above.
tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 1839
Quoted 13 lines
tools/xl/xl_parse.c +3
-0+ } + e =libxl_smbios_type_from_string (option, &v);if (e) { fprintf(stderr,@@ -1819,6 +1833,7 @@ void parse_config_data(const char *config_source, b_info->u.hvm.smbios[i].value = value; }break ; + }case ESRCH :break ;/* Option not present */ default :fprintf (stderr,"xl: Unable to parse smbios options.\n" );
Thanks,
Signature · 1 line
Anthony PERARD
Re: [PATCH 3/3] xl/libxl: Add OEM string support to smbios
Quoted 24 lines · Anthony PERARD
Quoted 22 lines · Jason Andryuk
Add support for OEM strings in the SMBIOS type 11.
hvmloader checks them sequentially, so hide the implementation detail. Allow multiple plain oem= items and assign the numeric values internally.
Signed-off-by Jason Andryuk <[email protected]>--- docs/man/xl.cfg.5.pod.in | 4 ++ tools/golang/xenlight/types.gen.go | 99 ++++++++++++++++++++++++++++++ tools/libs/light/libxl_types.idl | 99 ++++++++++++++++++++++++++++++ tools/xl/xl_parse.c | 15 +++++ 4 files changed, 217 insertions(+)docs/man/xl.cfg.5.pod.in +0
-0@@ -2104,8 +2104,12 @@ Each B<SMBIOS_SPEC_STRING> is a C<KEY=VALUE> string from the following list: =item B<battery_device_name=STRING>
Quoted 7 lines
docs/man/xl.cfg.5.pod.in Each B<SMBIOS_SPEC_STRING> is a C<KEY=VALUE> string from the following list: · line 2111
Quoted 5 lines
docs/man/xl.cfg.5.pod.in +3
-0+=item B<oem=STRING> + =back +oem= strings can be specified mutiple times up to a limit of 99.This could be move to just before =back I think.
Moved like you suggest, the man page output is:
"""
oem=STRING
oem= strings can be specified mutiple times up to a limit of 99.
ms_vm_genid="OPTION"
"""
I'll also re-word to "oem= can be specified up to 99 times."
Quoted 19 lines
Quoted 15 lines
docs/man/xl.cfg.5.pod.in +1
-0+ =item B<ms_vm_genid="OPTION"> Provide a VM generation ID to the guest.tools/libs/light/libxl_types.idl +3
-0@@ -436,6 +436,105 @@ libxl_smbios_type = Enumeration("smbios_type", [ (15, "enclosure_asset_tag"), (16, "battery_manufacturer"), (17, "battery_device_name"), + (18, "oem_1"), + (19, "oem_2"), + (20, "oem_3"),[...]
tools/libs/light/libxl_types.idl libxl_smbios_type = Enumeration("smbios_type", [ · line 537
Quoted 2 lines
tools/libs/light/libxl_types.idl +2
-0+ (115, "oem_98"), + (116, "oem_99"),
Quoted 6 lines
Instead of this long lists of enum value, could we just have one "oem" type, and allow it to be used more than once? I know that would mean having a special case in libxl, but that also mean that libxl will be the only one to deal with the implementation detail on how to write oem string for hvmloader (as opposed to deal with this in every application using libxl).
I'll pursue a single "oem" type. Also, I'll check the count in both libxl and xl. While only the libxl check is needed, it seems better to detect issues while parsing the config instead of only later during the domain build.
Thanks,
Jason