Page MenuHomeFreeBSD

D34465.id103556.diff
No OneTemporary

D34465.id103556.diff

diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5
--- a/usr.sbin/bhyve/bhyve_config.5
+++ b/usr.sbin/bhyve/bhyve_config.5
@@ -158,6 +158,76 @@
.Xr bhyve 8
will write all of its configuration variables to stdout and exit.
No VM will be started.
+.It Va bios.vendor Ta string Ta BHYVE Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va bios.version Ta string Ta 14.0 Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va bios.release_date Ta string Ta 10/17/2021 Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va system.family_name Ta string Ta Virtual Machine Ta
+Family the computer belongs to.
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va system.manufacturer Ta string Ta FreeBSD Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va system.product_name Ta string Ta BHYVE Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va system.serial_number Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va system.sku Ta string Ta None Ta
+Stock keeping unit of the computer.
+It's also called product ID or purchase order number.
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va system.version Ta string Ta 1.0 Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va board.manufacturer Ta string Ta FreeBSD Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va board.product_name Ta string Ta BHYVE Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va board.version Ta string Ta 1.0 Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va board.serial_number Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va board.asset_tag Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va board.location Ta string Ta None Ta
+Describes the board's location within the chassis.
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va chassis.manufacturer Ta string Ta FreeBSD Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va chassis.version Ta string Ta 1.0 Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va chassis.serial_number Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va chassis.asset_tag Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va chassis.sku Ta string Ta None Ta
+Stock keeping unit of the chassis.
+It's also called product ID or purchase order number.
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va processor.socket_designation Ta string Ta " " Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va processor.manufacturer Ta string Ta " " Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va processor.version Ta string Ta " " Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va processor.serial_number Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va processor.asset_tag Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va processor.part_number Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va memdevice.device_locator Ta string Ta " " Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va memdevice.physical_bank_locator Ta string Ta " " Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va memdevice.manufacturer Ta string Ta " " Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va memdevice.serial_number Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va memdevice.asset_tag Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va memdevice.part_number Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
.El
.Ss x86-Specific Settings
.Bl -column "x86.vmexit_on_pause" "integer" "Default"
diff --git a/usr.sbin/bhyve/smbiostbl.c b/usr.sbin/bhyve/smbiostbl.c
--- a/usr.sbin/bhyve/smbiostbl.c
+++ b/usr.sbin/bhyve/smbiostbl.c
@@ -35,6 +35,7 @@
#include <errno.h>
#include <md5.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <uuid.h>
@@ -76,13 +77,18 @@
uint16_t handle;
} __packed;
+struct smbios_config {
+ const char *name;
+ const char *string;
+};
+
typedef int (*initializer_func_t)(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
+ struct smbios_config *template_config, char *curaddr, char **endaddr,
uint16_t *n, uint16_t *size);
struct smbios_template_entry {
struct smbios_structure *entry;
- const char **strings;
+ struct smbios_config *config;
initializer_func_t initializer;
};
@@ -350,11 +356,11 @@
0xff /* embedded controller firmware minor release */
};
-const char *smbios_type0_strings[] = {
- "BHYVE", /* vendor string */
- FIRMWARE_VERSION, /* bios version string */
- FIRMWARE_RELEASE_DATE, /* bios release date string */
- NULL
+struct smbios_config smbios_type0_config[] = {
+ { "bios.vendor", "BHYVE" }, /* vendor string */
+ { "bios.version", FIRMWARE_VERSION }, /* bios version string */
+ { "bios.release_date", FIRMWARE_RELEASE_DATE }, /* bios release date string */
+ { 0 }
};
struct smbios_table_type1 smbios_type1_template = {
@@ -370,17 +376,17 @@
};
static int smbios_type1_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
+ struct smbios_config *template_config, char *curaddr, char **endaddr,
uint16_t *n, uint16_t *size);
-const char *smbios_type1_strings[] = {
- "FreeBSD", /* manufacturer string */
- "BHYVE", /* product name string */
- "1.0", /* version string */
- "None", /* serial number string */
- "None", /* sku string */
- "Virtual Machine", /* family name string */
- NULL
+struct smbios_config smbios_type1_config[] = {
+ { "system.manufacturer", "FreeBSD" }, /* manufacturer string */
+ { "system.product_name", "BHYVE" }, /* product string */
+ { "system.version", "1.0" }, /* version string */
+ { "system.serial_number", "None" }, /* serial number string */
+ { "system.sku", "None" }, /* sku string */
+ { "system.family_name", "Virtual Machine" }, /* family string */
+ { 0 }
};
struct smbios_table_type2 smbios_type2_template = {
@@ -397,14 +403,14 @@
0
};
-const char *smbios_type2_strings[] = {
- "FreeBSD", /* manufacturer string */
- "BHYVE", /* product name string */
- "1.0", /* version string */
- "None", /* serial number string */
- "None", /* asset tag string */
- "None", /* location string */
- NULL
+struct smbios_config smbios_type2_config[] = {
+ { "board.manufacturer", "FreeBSD" }, /* manufacturer string */
+ { "board.product_name", "BHYVE" }, /* product name string */
+ { "board.version", "1.0" }, /* version string */
+ { "board.serial_number", "None" }, /* serial number string */
+ { "board.asset_tag", "None" }, /* asset tag string */
+ { "board.location", "None" }, /* location string */
+ { 0 }
};
struct smbios_table_type3 smbios_type3_template = {
@@ -426,13 +432,13 @@
5 /* sku number string */
};
-const char *smbios_type3_strings[] = {
- "FreeBSD", /* manufacturer string */
- "1.0", /* version string */
- "None", /* serial number string */
- "None", /* asset tag string */
- "None", /* sku number string */
- NULL
+struct smbios_config smbios_type3_config[] = {
+ { "chassis.manufacturer", "FreeBSD" }, /* manufacturer string */
+ { "chassis.version", "1.0" }, /* version string */
+ { "chassis.serial_number", "None" }, /* serial number string */
+ { "chassis.asset_tag", "None" }, /* asset tag string */
+ { "chassis.sku", "None" }, /* sku number string */
+ { 0 }
};
struct smbios_table_type4 smbios_type4_template = {
@@ -462,18 +468,18 @@
SMBIOS_PRF_OTHER
};
-const char *smbios_type4_strings[] = {
- " ", /* socket designation string */
- " ", /* manufacturer string */
- " ", /* version string */
- "None", /* serial number string */
- "None", /* asset tag string */
- "None", /* part number string */
- NULL
+struct smbios_config smbios_type4_config[] = {
+ { "processor.socket_designation", " " }, /* socket designation string */
+ { "processor.manufacturer", " " }, /* manufacturer string */
+ { "processor.version", " " }, /* version string */
+ { "processor.serial_number", "None" }, /* serial number string */
+ { "processor.asset_tag", "None" }, /* asset tag string */
+ { "processor.part_number", "None" }, /* part number string */
+ { 0 }
};
static int smbios_type4_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
+ struct smbios_config *template_config, char *curaddr, char **endaddr,
uint16_t *n, uint16_t *size);
struct smbios_table_type16 smbios_type16_template = {
@@ -488,7 +494,7 @@
};
static int smbios_type16_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
+ struct smbios_config *template_config, char *curaddr, char **endaddr,
uint16_t *n, uint16_t *size);
struct smbios_table_type17 smbios_type17_template = {
@@ -517,18 +523,18 @@
0 /* configured voltage in mv (0=unknown) */
};
-const char *smbios_type17_strings[] = {
- " ", /* device locator string */
- " ", /* physical bank locator string */
- " ", /* manufacturer string */
- "None", /* serial number string */
- "None", /* asset tag string */
- "None", /* part number string */
- NULL
+struct smbios_config smbios_type17_config[] = {
+ { "memdevice.device_locator", " " }, /* device locator string */
+ { "memdevice.physical_bank_locator", " " }, /* physical bank locator string */
+ { "memdevice.manufacturer", " " }, /* manufacturer string */
+ { "memdevice.serial_number", "None" }, /* serial number string */
+ { "memdevice.asset_tag", "None" }, /* asset tag string */
+ { "memdevice.part_number", "None" }, /* part number string */
+ { 0 }
};
static int smbios_type17_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
+ struct smbios_config *template_config, char *curaddr, char **endaddr,
uint16_t *n, uint16_t *size);
struct smbios_table_type19 smbios_type19_template = {
@@ -542,7 +548,7 @@
};
static int smbios_type19_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
+ struct smbios_config *template_config, char *curaddr, char **endaddr,
uint16_t *n, uint16_t *size);
struct smbios_table_type32 smbios_type32_template = {
@@ -556,30 +562,30 @@
};
static int smbios_generic_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
+ struct smbios_config *template_config, char *curaddr, char **endaddr,
uint16_t *n, uint16_t *size);
static struct smbios_template_entry smbios_template[] = {
{ (struct smbios_structure *)&smbios_type0_template,
- smbios_type0_strings,
+ smbios_type0_config,
smbios_generic_initializer },
{ (struct smbios_structure *)&smbios_type1_template,
- smbios_type1_strings,
+ smbios_type1_config,
smbios_type1_initializer },
{ (struct smbios_structure *)&smbios_type2_template,
- smbios_type2_strings,
+ smbios_type2_config,
smbios_generic_initializer },
{ (struct smbios_structure *)&smbios_type3_template,
- smbios_type3_strings,
+ smbios_type3_config,
smbios_generic_initializer },
{ (struct smbios_structure *)&smbios_type4_template,
- smbios_type4_strings,
+ smbios_type4_config,
smbios_type4_initializer },
{ (struct smbios_structure *)&smbios_type16_template,
NULL,
smbios_type16_initializer },
{ (struct smbios_structure *)&smbios_type17_template,
- smbios_type17_strings,
+ smbios_type17_config,
smbios_type17_initializer },
{ (struct smbios_structure *)&smbios_type19_template,
NULL,
@@ -598,7 +604,7 @@
static int
smbios_generic_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
+ struct smbios_config *template_config, char *curaddr, char **endaddr,
uint16_t *n, uint16_t *size)
{
struct smbios_structure *entry;
@@ -607,14 +613,15 @@
entry = (struct smbios_structure *)curaddr;
entry->handle = *n + 1;
curaddr += entry->length;
- if (template_strings != NULL) {
+ if (template_config != NULL) {
int i;
- for (i = 0; template_strings[i] != NULL; i++) {
+ for (i = 0; template_config[i].name != NULL; i++) {
const char *string;
int len;
- string = template_strings[i];
+ set_config_value_if_unset(template_config[i].name, template_config[i].string);
+ string = get_config_value(template_config[i].name);
len = strlen(string) + 1;
memcpy(curaddr, string, len);
curaddr += len;
@@ -636,13 +643,13 @@
static int
smbios_type1_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
+ struct smbios_config *template_config, char *curaddr, char **endaddr,
uint16_t *n, uint16_t *size)
{
struct smbios_table_type1 *type1;
const char *guest_uuid_str;
- smbios_generic_initializer(template_entry, template_strings,
+ smbios_generic_initializer(template_entry, template_config,
curaddr, endaddr, n, size);
type1 = (struct smbios_table_type1 *)curaddr;
@@ -692,7 +699,7 @@
static int
smbios_type4_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
+ struct smbios_config *template_config, char *curaddr, char **endaddr,
uint16_t *n, uint16_t *size)
{
int i;
@@ -702,7 +709,7 @@
char *p;
int nstrings, len;
- smbios_generic_initializer(template_entry, template_strings,
+ smbios_generic_initializer(template_entry, template_config,
curaddr, endaddr, n, size);
type4 = (struct smbios_table_type4 *)curaddr;
p = curaddr + sizeof (struct smbios_table_type4);
@@ -734,13 +741,13 @@
static int
smbios_type16_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
+ struct smbios_config *template_config, char *curaddr, char **endaddr,
uint16_t *n, uint16_t *size)
{
struct smbios_table_type16 *type16;
type16_handle = *n;
- smbios_generic_initializer(template_entry, template_strings,
+ smbios_generic_initializer(template_entry, template_config,
curaddr, endaddr, n, size);
type16 = (struct smbios_table_type16 *)curaddr;
type16->xsize = guest_lomem + guest_himem;
@@ -751,13 +758,13 @@
static int
smbios_type17_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
+ struct smbios_config *template_config, char *curaddr, char **endaddr,
uint16_t *n, uint16_t *size)
{
struct smbios_table_type17 *type17;
uint64_t memsize, size_KB, size_MB;
- smbios_generic_initializer(template_entry, template_strings,
+ smbios_generic_initializer(template_entry, template_config,
curaddr, endaddr, n, size);
type17 = (struct smbios_table_type17 *)curaddr;
type17->arrayhand = type16_handle;
@@ -795,12 +802,12 @@
static int
smbios_type19_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
+ struct smbios_config *template_config, char *curaddr, char **endaddr,
uint16_t *n, uint16_t *size)
{
struct smbios_table_type19 *type19;
- smbios_generic_initializer(template_entry, template_strings,
+ smbios_generic_initializer(template_entry, template_config,
curaddr, endaddr, n, size);
type19 = (struct smbios_table_type19 *)curaddr;
type19->arrayhand = type16_handle;
@@ -809,7 +816,7 @@
if (guest_himem > 0) {
curaddr = *endaddr;
- smbios_generic_initializer(template_entry, template_strings,
+ smbios_generic_initializer(template_entry, template_config,
curaddr, endaddr, n, size);
type19 = (struct smbios_table_type19 *)curaddr;
type19->arrayhand = type16_handle;
@@ -892,16 +899,16 @@
maxssize = 0;
for (i = 0; smbios_template[i].entry != NULL; i++) {
struct smbios_structure *entry;
- const char **strings;
+ struct smbios_config *config;
initializer_func_t initializer;
char *endaddr;
uint16_t size;
entry = smbios_template[i].entry;
- strings = smbios_template[i].strings;
+ config = smbios_template[i].config;
initializer = smbios_template[i].initializer;
- err = (*initializer)(entry, strings, curaddr, &endaddr,
+ err = (*initializer)(entry, config, curaddr, &endaddr,
&n, &size);
if (err != 0)
return (err);

File Metadata

Mime Type
text/plain
Expires
Sun, Jul 19, 5:07 AM (11 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35221723
Default Alt Text
D34465.id103556.diff (17 KB)

Event Timeline