aboutsummaryrefslogtreecommitdiff
path: root/hw/smbios
diff options
context:
space:
mode:
authorLike Xu <like.xu@linux.intel.com>2019-05-19 04:54:20 +0800
committerEduardo Habkost <ehabkost@redhat.com>2019-07-05 17:07:36 -0300
commita0628599fa72524a1f59bbaa7410e6825a8feb3f (patch)
tree217e3b8e376d07c8f4078b926face539eb8ba6c8 /hw/smbios
parentedeeec911702870adf8866311b5feb2bdaaee2ce (diff)
downloadqemu-a0628599fa72524a1f59bbaa7410e6825a8feb3f.zip
qemu-a0628599fa72524a1f59bbaa7410e6825a8feb3f.tar.gz
qemu-a0628599fa72524a1f59bbaa7410e6825a8feb3f.tar.bz2
machine: Refactor smp-related call chains to pass MachineState
To get rid of the global smp_* variables we're currently using, it's recommended to pass MachineState in the list of incoming parameters for functions that use global smp variables, thus some redundant parameters are dropped. It's applied for legacy smbios_*(), *_machine_reset(), hot_add_cpu() and mips *_create_cpu(). Suggested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Like Xu <like.xu@linux.intel.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20190518205428.90532-3-like.xu@linux.intel.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'hw/smbios')
-rw-r--r--hw/smbios/smbios.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index a36448f..7bcd67b 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -27,6 +27,7 @@
#include "sysemu/cpus.h"
#include "hw/firmware/smbios.h"
#include "hw/loader.h"
+#include "hw/boards.h"
#include "exec/cpu-common.h"
#include "smbios_build.h"
@@ -341,9 +342,10 @@ static void smbios_register_config(void)
opts_init(smbios_register_config);
-static void smbios_validate_table(void)
+static void smbios_validate_table(MachineState *ms)
{
- uint32_t expect_t4_count = smbios_legacy ? smp_cpus : smbios_smp_sockets;
+ uint32_t expect_t4_count = smbios_legacy ?
+ ms->smp.cpus : smbios_smp_sockets;
if (smbios_type4_count && smbios_type4_count != expect_t4_count) {
error_report("Expected %d SMBIOS Type 4 tables, got %d instead",
@@ -428,7 +430,7 @@ static void smbios_build_type_1_fields(void)
}
}
-uint8_t *smbios_get_table_legacy(size_t *length)
+uint8_t *smbios_get_table_legacy(MachineState *ms, size_t *length)
{
if (!smbios_legacy) {
*length = 0;
@@ -438,7 +440,7 @@ uint8_t *smbios_get_table_legacy(size_t *length)
if (!smbios_immutable) {
smbios_build_type_0_fields();
smbios_build_type_1_fields();
- smbios_validate_table();
+ smbios_validate_table(ms);
smbios_immutable = true;
}
*length = smbios_entries_len;
@@ -570,7 +572,7 @@ static void smbios_build_type_3_table(void)
SMBIOS_BUILD_TABLE_POST;
}
-static void smbios_build_type_4_table(unsigned instance)
+static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
{
char sock_str[128];
@@ -597,8 +599,8 @@ static void smbios_build_type_4_table(unsigned instance)
SMBIOS_TABLE_SET_STR(4, serial_number_str, type4.serial);
SMBIOS_TABLE_SET_STR(4, asset_tag_number_str, type4.asset);
SMBIOS_TABLE_SET_STR(4, part_number_str, type4.part);
- t->core_count = t->core_enabled = smp_cores;
- t->thread_count = smp_threads;
+ t->core_count = t->core_enabled = ms->smp.cores;
+ t->thread_count = ms->smp.threads;
t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
t->processor_family2 = cpu_to_le16(0x01); /* Other */
@@ -839,7 +841,8 @@ static void smbios_entry_point_setup(void)
}
}
-void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
+void smbios_get_tables(MachineState *ms,
+ const struct smbios_phys_mem_area *mem_array,
const unsigned int mem_array_size,
uint8_t **tables, size_t *tables_len,
uint8_t **anchor, size_t *anchor_len)
@@ -858,11 +861,12 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
smbios_build_type_2_table();
smbios_build_type_3_table();
- smbios_smp_sockets = DIV_ROUND_UP(smp_cpus, smp_cores * smp_threads);
+ smbios_smp_sockets = DIV_ROUND_UP(ms->smp.cpus,
+ ms->smp.cores * ms->smp.threads);
assert(smbios_smp_sockets >= 1);
for (i = 0; i < smbios_smp_sockets; i++) {
- smbios_build_type_4_table(i);
+ smbios_build_type_4_table(ms, i);
}
smbios_build_type_11_table();
@@ -888,7 +892,7 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
smbios_build_type_38_table();
smbios_build_type_127_table();
- smbios_validate_table();
+ smbios_validate_table(ms);
smbios_entry_point_setup();
smbios_immutable = true;
}