[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/3] xl/libxl: Add OEM string support to smbios


  • To: Jason Andryuk <jandryuk@xxxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Thu, 8 Sep 2022 14:14:43 +0100
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Nick Rosbrook <rosbrookn@xxxxxxxxx>, "Juergen Gross" <jgross@xxxxxxxx>
  • Delivery-date: Thu, 08 Sep 2022 13:15:01 +0000
  • Ironport-data: A9a23:oSu5DK5VsFIkfZ1i6+E8bgxRtDDHchMFZxGqfqrLsTDasY5as4F+v mccUDzQbvmLNGryL4x2Pdng8UlQvpSHn4RmGQprqXw8Hi5G8cbLO4+Ufxz6V8+wwmwvb67FA +E2MISowBUcFyeEzvuVGuG96yM6jclkf5KkYMbcICd9WAR4fykojBNnioYRj5VhxNO0GGthg /uryyHkEALjimUc3l48sfrZ8ks+5KSq4lv0g3RlDRx1lA6G/5UqJMp3yZGZdxPQXoRSF+imc OfPpJnRErTxpkpF5nuNy94XQ2VSKlLgFVHmZkl+AsBOtiNqtC0qupvXAdJHAathZ5dlqPgqo DlFncTYpQ7EpcQgksxFO/VTO3kW0aGrZNYriJVw2CCe5xSuTpfi/xlhJB41JKA8oepYOzlHz NgnJBdVUhmapcvjldpXSsE07igiBMziPYdZsXB81zDJS/0hRPgvQY2Tu4Uehm1pwJkTQ7COP KL1ahI2BPjESxRJJlcQDoN4hOqyj2PzWzZZtEiUtew85G27IAlZj+mybYCPI4ziqcN9nAGi/ mmd3kfDLDIDaN6fxjjZ33yNmbqa9c/8cN1LT+DpnhJwu3WJwXcZEhoRVl2Trvywi0r4UNVaQ 2QW9TAptrMa71GwQ5/2WBjQiGGAlg4RXZxXCeJSwAOEzKbO8huaLmcBRz9FLtchsaceVTEsk 1OEgd7tLThuq6GOD2KQ8K+OqjG/MjRTKnUNDRLoViNcvYOl+ttqyEuSEJAzS8ZZk+EZBxmvw CmniHMyqI9LhPcv6KmcpWzOmhCF882hohEO2unHYo60xlonOtT7PNXztQezAeVod9jAEATY1 JQQs43Htb1VU8nQ/MCYaL9VdIxF8cppJ9E1bbRHO5A6vwqg9He4FWy7yGEvfRw5WirolNKAX aMyhe+yzMUJVJdSRfUrC79d8uxzpUQaKfzrV+rPcv1FaYVreQmM8UlGPBDOhT2yzRd8yv1mZ /93lPpA6l5DUMxaIMeeHb9BgdfHOAhlrY8seXwL50v+iufPDJJkYbwELEGPfogE0U9wmy2Mq o43Cid/408AOAEISnWIrNV7wJFjBSRTOK0aXOQGKbXTeVQ5RTxJ5j246epJRrGJVp99zo/gl kxRkGcBoLYjrRUr8Tm3V00=
  • Ironport-hdrordr: A9a23:YtNMIKBCUcuNNVzlHems55DYdb4zR+YMi2TC1yhKJyC9Vvbo8/ xG/c5rsCMc5wx9ZJhNo7y90ey7MBThHP1OkOss1NWZPDUO0VHAROoJ0WKh+UyCJ8SXzJ866U 4KSclD4bPLYmRHsQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Aug 10, 2022 at 03:48:27PM -0400, Jason Andryuk wrote:
> 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 <jandryuk@xxxxxxxxx>
> ---
>  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(+)
> 
> diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
> index 7edf5d23f3..7947bf07ea 100644
> --- a/docs/man/xl.cfg.5.pod.in
> +++ b/docs/man/xl.cfg.5.pod.in
> @@ -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.

> +
>  =item B<ms_vm_genid="OPTION">
>  
>  Provide a VM generation ID to the guest.
> diff --git a/tools/libs/light/libxl_types.idl 
> b/tools/libs/light/libxl_types.idl
> index d04207748e..58f404af37 100644
> --- a/tools/libs/light/libxl_types.idl
> +++ b/tools/libs/light/libxl_types.idl
> @@ -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"),
[...]
> +    (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).

>      ])
>  
>  libxl_smbios = Struct("smbios", [
> diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
> index 4f3f962773..fb7f1f6867 100644
> --- a/tools/xl/xl_parse.c
> +++ b/tools/xl/xl_parse.c
> @@ -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;

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.

> +                }
> +
>                  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,

-- 
Anthony PERARD



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.