yeahuh / rpms / qemu-kvm

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