xl/libxl: Add OEM string support to smbios

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@gmail.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
This commit is contained in:
Jason Andryuk authored and Andrew Cooper committed 2023-03-15 18:41:46 +00:00
1 parent 9aeb3a20c4
commit 38bdfa44cc
5 files changed
+33 -2

No files matched your search

+4
View File
@@ -2122,6 +2122,10 @@ 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>
oem= can be specified up to 99 times.
=back
=item B<ms_vm_genid="OPTION">
+1
View File
@@ -411,6 +411,7 @@ SmbiosTypeEnclosureSerialNumber SmbiosType = 14
SmbiosTypeEnclosureAssetTag SmbiosType = 15
SmbiosTypeBatteryManufacturer SmbiosType = 16
SmbiosTypeBatteryDeviceName SmbiosType = 17
SmbiosTypeOem SmbiosType = 18
)
type Smbios struct {
+14 -2
View File
@@ -755,6 +755,7 @@ static int hvm_build_set_xs_values(libxl__gc *gc,
const libxl_domain_build_info *info)
{
char *path = NULL;
int num_oem = 1;
int ret = 0;
if (dom->smbios_module.guest_addr_out) {
@@ -775,8 +776,19 @@ static int hvm_build_set_xs_values(libxl__gc *gc,
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));
if (info->u.hvm.smbios[i].key == LIBXL_SMBIOS_TYPE_OEM) {
if (num_oem > 99) {
LOGD(ERROR, domid, "More than 99 SMBIOS OEM strings specified");
ret = ERROR_INVAL;
goto err;
}
path = GCSPRINTF("/local/domain/%d/"HVM_XS_OEM_STRINGS, domid,
num_oem);
num_oem++;
} else {
path = GCSPRINTF("/local/domain/%d/"HVM_XS_BIOS_STRINGS"/%s", domid,
libxl_smbios_type_to_string(info->u.hvm.smbios[i].key));
}
/* Convert libxl_smbios_type string to xenstore path that hvmloader
* will use, as defined by HVM_XS_*. That is convert the '_' to '-'. */
+1
View File
@@ -441,6 +441,7 @@ libxl_smbios_type = Enumeration("smbios_type", [
(15, "enclosure_asset_tag"),
(16, "battery_manufacturer"),
(17, "battery_device_name"),
(18, "oem"),
])
libxl_smbios = Struct("smbios", [
+13
View File
@@ -1864,6 +1864,9 @@ 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++) {
@@ -1903,12 +1906,22 @@ void parse_config_data(const char *config_source,
exit(EXIT_FAILURE);
}
if (type == LIBXL_SMBIOS_TYPE_OEM) {
if (num_oem > 99) {
fprintf(stderr,
"xl: smbios limited to 99 oem strings\n");
exit(EXIT_FAILURE);
}
num_oem++;
}
b_info->u.hvm.smbios[i].key = type;
b_info->u.hvm.smbios[i].value = xstrdup(value);
free(option);
}
break;
}
case ESRCH: /* Option not present */
break;
default:
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.