cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From 1123ee2cf18b526b19fc3770f20c91b1ac409cf7 Mon Sep 17 00:00:00 2001
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
Date: Sat, 2 Nov 2013 10:01:26 +0100
9ae3a8
Subject: [PATCH 26/29] smbios: Set system manufacturer, product & version by default
9ae3a8
9ae3a8
RH-Author: Markus Armbruster <armbru@redhat.com>
9ae3a8
Message-id: <1383386488-29789-10-git-send-email-armbru@redhat.com>
9ae3a8
Patchwork-id: 55245
9ae3a8
O-Subject: [PATCH 7.0 qemu-kvm 09/11] smbios: Set system manufacturer, product & version by default
9ae3a8
Bugzilla: 994490
9ae3a8
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
9ae3a8
Currently, we get SeaBIOS defaults: manufacturer Bochs, product Bochs,
9ae3a8
no version.  Best SeaBIOS can do, but we can provide better defaults:
9ae3a8
manufacturer QEMU, product & version taken from QEMUMachine desc and
9ae3a8
name.
9ae3a8
9ae3a8
Take care to do this only for new machine types, of course.
9ae3a8
9ae3a8
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
(cherry picked from pending upstream submission)
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	hw/i386/pc_piix.c
9ae3a8
	hw/i386/pc_q35.c
9ae3a8
---
9ae3a8
 hw/i386/pc_piix.c        |  7 +++++++
9ae3a8
 hw/i386/pc_q35.c         |  7 +++++++
9ae3a8
 hw/i386/smbios.c         | 14 ++++++++++++++
9ae3a8
 include/hw/i386/smbios.h |  2 ++
9ae3a8
 4 files changed, 30 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/i386/pc_piix.c        |    7 +++++++
9ae3a8
 hw/i386/pc_q35.c         |    7 +++++++
9ae3a8
 hw/i386/smbios.c         |   14 ++++++++++++++
9ae3a8
 include/hw/i386/smbios.h |    2 ++
9ae3a8
 4 files changed, 30 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
9ae3a8
index 65f7f3a..e8fe607 100644
9ae3a8
--- a/hw/i386/pc_piix.c
9ae3a8
+++ b/hw/i386/pc_piix.c
9ae3a8
@@ -27,6 +27,7 @@
9ae3a8
 #include "hw/hw.h"
9ae3a8
 #include "hw/i386/pc.h"
9ae3a8
 #include "hw/i386/apic.h"
9ae3a8
+#include "hw/i386/smbios.h"
9ae3a8
 #include "hw/pci/pci.h"
9ae3a8
 #include "hw/pci/pci_ids.h"
9ae3a8
 #include "hw/usb.h"
9ae3a8
@@ -57,6 +58,7 @@ static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
9ae3a8
 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
9ae3a8
 
9ae3a8
 static bool has_pvpanic = true;
9ae3a8
+static bool smbios_type1_defaults = true;
9ae3a8
 
9ae3a8
 /* PC hardware initialisation */
9ae3a8
 static void pc_init1(QEMUMachineInitArgs *args,
9ae3a8
@@ -113,6 +115,11 @@ static void pc_init1(QEMUMachineInitArgs *args,
9ae3a8
         rom_memory = system_memory;
9ae3a8
     }
9ae3a8
 
9ae3a8
+    if (smbios_type1_defaults) {
9ae3a8
+        smbios_set_type1_defaults("QEMU", args->machine->desc,
9ae3a8
+                                  args->machine->name);
9ae3a8
+    }
9ae3a8
+
9ae3a8
     /* allocate ram and load rom/bios */
9ae3a8
     if (!xen_enabled()) {
9ae3a8
         fw_cfg = pc_memory_init(system_memory,
9ae3a8
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
9ae3a8
index 99d3a10..3ef854a 100644
9ae3a8
--- a/hw/i386/pc_q35.c
9ae3a8
+++ b/hw/i386/pc_q35.c
9ae3a8
@@ -38,6 +38,7 @@
9ae3a8
 #include "hw/pci-host/q35.h"
9ae3a8
 #include "exec/address-spaces.h"
9ae3a8
 #include "hw/i386/ich9.h"
9ae3a8
+#include "hw/i386/smbios.h"
9ae3a8
 #include "hw/ide/pci.h"
9ae3a8
 #include "hw/ide/ahci.h"
9ae3a8
 #include "hw/usb.h"
9ae3a8
@@ -47,6 +48,7 @@
9ae3a8
 #define MAX_SATA_PORTS     6
9ae3a8
 
9ae3a8
 static bool has_pvpanic = true;
9ae3a8
+static bool smbios_type1_defaults = true;
9ae3a8
 
9ae3a8
 /* PC hardware initialisation */
9ae3a8
 static void pc_q35_init(QEMUMachineInitArgs *args)
9ae3a8
@@ -99,6 +101,11 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
9ae3a8
         rom_memory = get_system_memory();
9ae3a8
     }
9ae3a8
 
9ae3a8
+    if (smbios_type1_defaults) {
9ae3a8
+        smbios_set_type1_defaults("QEMU", args->machine->desc,
9ae3a8
+                                  args->machine->name);
9ae3a8
+    }
9ae3a8
+
9ae3a8
     /* allocate ram and load rom/bios */
9ae3a8
     if (!xen_enabled()) {
9ae3a8
         pc_memory_init(get_system_memory(),
9ae3a8
diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
9ae3a8
index d3f1ee6..e8f41ad 100644
9ae3a8
--- a/hw/i386/smbios.c
9ae3a8
+++ b/hw/i386/smbios.c
9ae3a8
@@ -256,6 +256,20 @@ static void smbios_build_type_1_fields(void)
9ae3a8
     }
9ae3a8
 }
9ae3a8
 
9ae3a8
+void smbios_set_type1_defaults(const char *manufacturer,
9ae3a8
+                               const char *product, const char *version)
9ae3a8
+{
9ae3a8
+    if (!type1.manufacturer) {
9ae3a8
+        type1.manufacturer = manufacturer;
9ae3a8
+    }
9ae3a8
+    if (!type1.product) {
9ae3a8
+        type1.product = product;
9ae3a8
+    }
9ae3a8
+    if (!type1.version) {
9ae3a8
+        type1.version = version;
9ae3a8
+    }
9ae3a8
+}
9ae3a8
+
9ae3a8
 uint8_t *smbios_get_table(size_t *length)
9ae3a8
 {
9ae3a8
     if (!smbios_immutable) {
9ae3a8
diff --git a/include/hw/i386/smbios.h b/include/hw/i386/smbios.h
9ae3a8
index b08ec71..18fb970 100644
9ae3a8
--- a/include/hw/i386/smbios.h
9ae3a8
+++ b/include/hw/i386/smbios.h
9ae3a8
@@ -16,6 +16,8 @@
9ae3a8
 #include "qemu/option.h"
9ae3a8
 
9ae3a8
 void smbios_entry_add(QemuOpts *opts);
9ae3a8
+void smbios_set_type1_defaults(const char *manufacturer,
9ae3a8
+                               const char *product, const char *version);
9ae3a8
 uint8_t *smbios_get_table(size_t *length);
9ae3a8
 
9ae3a8
 /*
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8