Skip to content

Commit

Permalink
smbios: Set system manufacturer, product & version by default
Browse files Browse the repository at this point in the history
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.

Note: Michael Tsirkin doesn't trust us to keep values of QEMUMachine member
product stable in the future.  Use copies instead, and in a way that
makes it obvious that they're guest ABI.

Note that we can be trusted to keep values of member name, because
that has always been ABI.

Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
  • Loading branch information
Markus Armbruster authored and mstsirkin committed Dec 10, 2013
1 parent 026736c commit b29ad07
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
24 changes: 23 additions & 1 deletion hw/i386/pc_piix.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "hw/loader.h"
#include "hw/i386/pc.h"
#include "hw/i386/apic.h"
#include "hw/i386/smbios.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_ids.h"
#include "hw/usb.h"
Expand Down Expand Up @@ -59,6 +60,7 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };

static bool has_pci_info;
static bool has_acpi_build = true;
static bool smbios_type1_defaults = true;

/* PC hardware initialisation */
static void pc_init1(QEMUMachineInitArgs *args,
Expand Down Expand Up @@ -128,6 +130,12 @@ static void pc_init1(QEMUMachineInitArgs *args,
guest_info->has_pci_info = has_pci_info;
guest_info->isapc_ram_fw = !pci_enabled;

if (smbios_type1_defaults) {
/* These values are guest ABI, do not change */
smbios_set_type1_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
args->machine->name);
}

/* allocate ram and load rom/bios */
if (!xen_enabled()) {
fw_cfg = pc_memory_init(system_memory,
Expand Down Expand Up @@ -233,8 +241,14 @@ static void pc_init_pci(QEMUMachineInitArgs *args)
pc_init1(args, 1, 1);
}

static void pc_compat_1_7(QEMUMachineInitArgs *args)
{
smbios_type1_defaults = false;
}

static void pc_compat_1_6(QEMUMachineInitArgs *args)
{
pc_compat_1_7(args);
has_pci_info = false;
rom_file_in_ram = false;
has_acpi_build = false;
Expand Down Expand Up @@ -265,6 +279,12 @@ static void pc_compat_1_2(QEMUMachineInitArgs *args)
disable_kvm_pv_eoi();
}

static void pc_init_pci_1_7(QEMUMachineInitArgs *args)
{
pc_compat_1_7(args);
pc_init_pci(args);
}

static void pc_init_pci_1_6(QEMUMachineInitArgs *args)
{
pc_compat_1_6(args);
Expand Down Expand Up @@ -301,6 +321,7 @@ static void pc_init_pci_no_kvmclock(QEMUMachineInitArgs *args)
{
has_pci_info = false;
has_acpi_build = false;
smbios_type1_defaults = false;
disable_kvm_pv_eoi();
enable_compat_apic_id_mode();
pc_init1(args, 1, 0);
Expand All @@ -310,6 +331,7 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
{
has_pci_info = false;
has_acpi_build = false;
smbios_type1_defaults = false;
if (!args->cpu_model) {
args->cpu_model = "486";
}
Expand Down Expand Up @@ -354,7 +376,7 @@ static QEMUMachine pc_i440fx_machine_v2_0 = {
static QEMUMachine pc_i440fx_machine_v1_7 = {
PC_I440FX_1_7_MACHINE_OPTIONS,
.name = "pc-i440fx-1.7",
.init = pc_init_pci,
.init = pc_init_pci_1_7,
};

#define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
Expand Down
20 changes: 20 additions & 0 deletions hw/i386/pc_q35.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "hw/pci-host/q35.h"
#include "exec/address-spaces.h"
#include "hw/i386/ich9.h"
#include "hw/i386/smbios.h"
#include "hw/ide/pci.h"
#include "hw/ide/ahci.h"
#include "hw/usb.h"
Expand All @@ -49,6 +50,7 @@

static bool has_pci_info;
static bool has_acpi_build = true;
static bool smbios_type1_defaults = true;

/* PC hardware initialisation */
static void pc_q35_init(QEMUMachineInitArgs *args)
Expand Down Expand Up @@ -113,6 +115,12 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
guest_info->isapc_ram_fw = false;
guest_info->has_acpi_build = has_acpi_build;

if (smbios_type1_defaults) {
/* These values are guest ABI, do not change */
smbios_set_type1_defaults("QEMU", "Standard PC (Q35 + ICH9, 2009)",
args->machine->name);
}

/* allocate ram and load rom/bios */
if (!xen_enabled()) {
pc_memory_init(get_system_memory(),
Expand Down Expand Up @@ -217,8 +225,14 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
}
}

static void pc_compat_1_7(QEMUMachineInitArgs *args)
{
smbios_type1_defaults = false;
}

static void pc_compat_1_6(QEMUMachineInitArgs *args)
{
pc_compat_1_7(args);
has_pci_info = false;
rom_file_in_ram = false;
has_acpi_build = false;
Expand All @@ -236,6 +250,12 @@ static void pc_compat_1_4(QEMUMachineInitArgs *args)
x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
}

static void pc_q35_init_1_7(QEMUMachineInitArgs *args)
{
pc_compat_1_7(args);
pc_q35_init(args);
}

static void pc_q35_init_1_6(QEMUMachineInitArgs *args)
{
pc_compat_1_6(args);
Expand Down
14 changes: 14 additions & 0 deletions hw/i386/smbios.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,20 @@ static void smbios_build_type_1_fields(void)
}
}

void smbios_set_type1_defaults(const char *manufacturer,
const char *product, const char *version)
{
if (!type1.manufacturer) {
type1.manufacturer = manufacturer;
}
if (!type1.product) {
type1.product = product;
}
if (!type1.version) {
type1.version = version;
}
}

uint8_t *smbios_get_table(size_t *length)
{
if (!smbios_immutable) {
Expand Down
2 changes: 2 additions & 0 deletions include/hw/i386/smbios.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "qemu/option.h"

void smbios_entry_add(QemuOpts *opts);
void smbios_set_type1_defaults(const char *manufacturer,
const char *product, const char *version);
uint8_t *smbios_get_table(size_t *length);

/*
Expand Down

0 comments on commit b29ad07

Please sign in to comment.