qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 7/7] smbios: Set system manufacturer, product & vers


From: Markus Armbruster
Subject: [Qemu-devel] [PATCH 7/7] smbios: Set system manufacturer, product & version by default
Date: Wed, 17 Jul 2013 19:16:09 +0200

Currently, we get SeaBIOS defaults: manufacturer Bochs, product Bochs,
no version.  Best SeaBIOS can do, but we can provide better defaults:
manufacturer QEMU, product & version taken from QEMUMachine desc and
name.

Take care to do this only for new machine types, of course.

Signed-off-by: Markus Armbruster <address@hidden>
---
 hw/i386/pc.c             |  6 +++---
 hw/i386/pc_piix.c        |  5 +++++
 hw/i386/pc_q35.c         |  3 +++
 hw/i386/smbios.c         | 12 +++++++++++-
 include/hw/i386/pc.h     |  1 +
 include/hw/i386/smbios.h |  2 +-
 6 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index c5d8570..c427f9f 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -605,7 +605,7 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)
     return x86_cpu_apic_id_from_index(max_cpus - 1) + 1;
 }
 
-static FWCfgState *bochs_bios_init(void)
+static FWCfgState *bochs_bios_init(bool smbios_type1_defaults)
 {
     FWCfgState *fw_cfg;
     uint8_t *smbios_table;
@@ -636,7 +636,7 @@ static FWCfgState *bochs_bios_init(void)
                      acpi_tables, acpi_tables_len);
     fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override());
 
-    smbios_table = smbios_get_table(&smbios_len);
+    smbios_table = smbios_get_table(&smbios_len, smbios_type1_defaults);
     if (smbios_table)
         fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES,
                          smbios_table, smbios_len);
@@ -1146,7 +1146,7 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
                                         option_rom_mr,
                                         1);
 
-    fw_cfg = bochs_bios_init();
+    fw_cfg = bochs_bios_init(guest_info->smbios_type1_defaults);
     rom_set_fw(fw_cfg);
 
     if (linux_boot) {
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index b58c255..60bf752 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -58,6 +58,7 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
 
 static bool has_pvpanic = true;
 static bool has_pci_info = true;
+static bool smbios_type1_defaults = true;
 
 /* PC hardware initialisation */
 static void pc_init1(MemoryRegion *system_memory,
@@ -128,6 +129,7 @@ static void pc_init1(MemoryRegion *system_memory,
 
     guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
     guest_info->has_pci_info = has_pci_info;
+    guest_info->smbios_type1_defaults = smbios_type1_defaults;
 
     /* Set PCI window size the way seabios has always done it. */
     /* Power of 2 so bios can cover it with a single MTRR */
@@ -264,6 +266,7 @@ static void pc_init_pci(QEMUMachineInitArgs *args)
 static void pc_init_pci_1_5(QEMUMachineInitArgs *args)
 {
     has_pci_info = false;
+    smbios_type1_defaults = false;
     pc_init_pci(args);
 }
 
@@ -304,6 +307,7 @@ static void pc_init_pci_no_kvmclock(QEMUMachineInitArgs 
*args)
     const char *boot_device = args->boot_device;
     has_pvpanic = false;
     has_pci_info = false;
+    smbios_type1_defaults = false;
     disable_kvm_pv_eoi();
     enable_compat_apic_id_mode();
     pc_init1(get_system_memory(),
@@ -323,6 +327,7 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
     const char *boot_device = args->boot_device;
     has_pvpanic = false;
     has_pci_info = false;
+    smbios_type1_defaults = false;
     if (cpu_model == NULL)
         cpu_model = "486";
     disable_kvm_pv_eoi();
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 6f10246..c756474 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -48,6 +48,7 @@
 
 static bool has_pvpanic = true;
 static bool has_pci_info = true;
+static bool smbios_type1_defaults = true;
 
 /* PC hardware initialisation */
 static void pc_q35_init(QEMUMachineInitArgs *args)
@@ -109,6 +110,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
 
     guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
     guest_info->has_pci_info = has_pci_info;
+    guest_info->smbios_type1_defaults = smbios_type1_defaults;
 
     /* allocate ram and load rom/bios */
     if (!xen_enabled()) {
@@ -217,6 +219,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
 static void pc_q35_init_1_5(QEMUMachineInitArgs *args)
 {
     has_pci_info = false;
+    smbios_type1_defaults = false;
     pc_q35_init(args);
 }
 
diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
index a2eb9bf..e6413a5 100644
--- a/hw/i386/smbios.c
+++ b/hw/i386/smbios.c
@@ -18,6 +18,7 @@
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
 #include "sysemu/sysemu.h"
+#include "hw/boards.h"
 #include "hw/i386/smbios.h"
 #include "hw/loader.h"
 
@@ -256,9 +257,18 @@ static void smbios_build_type_1_fields(void)
     }
 }
 
-uint8_t *smbios_get_table(size_t *length)
+uint8_t *smbios_get_table(size_t *length, bool type1_defaults)
 {
     if (!smbios_immutable) {
+        if (type1_defaults && !type1.manufacturer) {
+            type1.manufacturer = "QEMU";
+        }
+        if (type1_defaults && !type1.product) {
+            type1.product = current_machine->desc;
+        }
+        if (type1_defaults && !type1.version) {
+            type1.version = current_machine->name;
+        }
         smbios_build_type_0_fields();
         smbios_build_type_1_fields();
         smbios_validate_table();
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 61ff154..860f2bb 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -20,6 +20,7 @@ typedef struct PcPciInfo {
 struct PcGuestInfo {
     PcPciInfo pci_info;
     bool has_pci_info;
+    bool smbios_type1_defaults;
     FWCfgState *fw_cfg;
 };
 
diff --git a/include/hw/i386/smbios.h b/include/hw/i386/smbios.h
index b08ec71..e258d9a 100644
--- a/include/hw/i386/smbios.h
+++ b/include/hw/i386/smbios.h
@@ -16,7 +16,7 @@
 #include "qemu/option.h"
 
 void smbios_entry_add(QemuOpts *opts);
-uint8_t *smbios_get_table(size_t *length);
+uint8_t *smbios_get_table(size_t *length, bool type1_defaults);
 
 /*
  * SMBIOS spec defined tables
-- 
1.7.11.7




reply via email to

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