So far we only mistakenly claimed support for selecting base board type. This patch finally implements it. There's an enum in SMBIOS specification that lays out all the possible values. Therefore, the type is taken as an integer of the corresponding string value.
Signed-off-by: Michal Privoznik <mpriv...@redhat.com> --- hw/i386/smbios.c | 18 +++++++++++++++++- qemu-options.hx | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c index 1341e02..b2f3809 100644 --- a/hw/i386/smbios.c +++ b/hw/i386/smbios.c @@ -79,6 +79,9 @@ static struct { static struct { const char *manufacturer, *product, *version, *serial, *asset, *location; + uint8_t family; /* It's called type in the specification, but + unfortunately that name is already taken + (to specify SMBIOS entry type). */ } type2; static struct { @@ -210,6 +213,10 @@ static const QemuOptDesc qemu_smbios_type2_opts[] = { .name = "location", .type = QEMU_OPT_STRING, .help = "location in chassis", + },{ + .name = "family", + .type = QEMU_OPT_NUMBER, + .help = "board type", }, { /* end of list */ } }; @@ -579,7 +586,7 @@ static void smbios_build_type_2_table(void) t->feature_flags = 0x01; /* Motherboard */ SMBIOS_TABLE_SET_STR(2, location_str, type2.location); t->chassis_handle = cpu_to_le16(0x300); /* Type 3 (System enclosure) */ - t->board_type = 0x0A; /* Motherboard */ + t->board_type = type2.family ? type2.family : 0x0A; /* Motherboard */ t->contained_element_count = 0; SMBIOS_BUILD_TABLE_POST; @@ -1050,6 +1057,15 @@ void smbios_entry_add(QemuOpts *opts) save_opt(&type2.serial, opts, "serial"); save_opt(&type2.asset, opts, "asset"); save_opt(&type2.location, opts, "location"); + + val = qemu_opt_get(opts, "family"); + if (val) { + if (sscanf(val, "%hhu", &type2.family) != 1 || + type2.family > 0x0D) { + error_report("Invalid base board type"); + exit(1); + } + } return; case 3: qemu_opts_validate(opts, qemu_smbios_type3_opts, &local_err); diff --git a/qemu-options.hx b/qemu-options.hx index ec356f6..ef78849 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1393,7 +1393,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, " [,uuid=uuid][,sku=str][,family=str]\n" " specify SMBIOS type 1 fields\n" "-smbios type=2[,manufacturer=str][,product=str][,version=str][,serial=str]\n" - " [,asset=str][,location=str]\n" + " [,asset=str][,location=str][,family=%d]\n" " specify SMBIOS type 2 fields\n" "-smbios type=3[,manufacturer=str][,version=str][,serial=str][,asset=str]\n" " [,sku=str]\n" @@ -1416,7 +1416,7 @@ Specify SMBIOS type 0 fields @item -smbios type=1[,manufacturer=@var{str}][,product=@var{str}][,version=@var{str}][,serial=@var{str}][,uuid=@var{uuid}][,sku=@var{str}][,family=@var{str}] Specify SMBIOS type 1 fields -@item -smbios type=2[,manufacturer=@var{str}][,product=@var{str}][,version=@var{str}][,serial=@var{str}][,asset=@var{str}][,location=@var{str}][,family=@var{str}] +@item -smbios type=2[,manufacturer=@var{str}][,product=@var{str}][,version=@var{str}][,serial=@var{str}][,asset=@var{str}][,location=@var{str}][,family=@var{%d}] Specify SMBIOS type 2 fields @item -smbios type=3[,manufacturer=@var{str}][,version=@var{str}][,serial=@var{str}][,asset=@var{str}][,sku=@var{str}] -- 2.3.6