qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 2/2] SMBIOS: Allow users to chose base board type


From: Michal Privoznik
Subject: [Qemu-devel] [PATCH 2/2] SMBIOS: Allow users to chose base board type
Date: Wed, 20 May 2015 11:15:50 +0200

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 <address@hidden>
---
 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[,address@hidden,address@hidden,address@hidden,address@hidden,address@hidden,address@hidden,address@hidden
 Specify SMBIOS type 1 fields
 
address@hidden -smbios 
type=2[,address@hidden,address@hidden,address@hidden,address@hidden,address@hidden,address@hidden,address@hidden
address@hidden -smbios 
type=2[,address@hidden,address@hidden,address@hidden,address@hidden,address@hidden,address@hidden,address@hidden
 Specify SMBIOS type 2 fields
 
 @item -smbios 
type=3[,address@hidden,address@hidden,address@hidden,address@hidden,address@hidden
-- 
2.3.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]