diff options
author | Like Xu | 2019-05-18 22:54:25 +0200 |
---|---|---|
committer | Eduardo Habkost | 2019-07-05 22:08:03 +0200 |
commit | 0e11fc6955dddf752987b261a0176edf31b34dec (patch) | |
tree | ecaeee904d31223fd77410dd8be6236ac33cb591 /hw/i386/pc.c | |
parent | hw/s390x: Replace global smp variables with machine smp properties (diff) | |
download | qemu-0e11fc6955dddf752987b261a0176edf31b34dec.tar.gz qemu-0e11fc6955dddf752987b261a0176edf31b34dec.tar.xz qemu-0e11fc6955dddf752987b261a0176edf31b34dec.zip |
hw/i386: Replace global smp variables with machine smp properties
The global smp variables in i386 are replaced with smp machine properties.
To avoid calling qdev_get_machine() as much as possible, some related funtions
for acpi data generations are refactored. No semantic changes.
A local variable of the same name would be introduced in the declaration
phase if it's used widely in the context OR replace it on the spot if it's
only used once. No semantic changes.
Signed-off-by: Like Xu <like.xu@linux.intel.com>
Message-Id: <20190518205428.90532-8-like.xu@linux.intel.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'hw/i386/pc.c')
-rw-r--r-- | hw/i386/pc.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0b0b55afd2..269e44f0d0 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -925,11 +925,13 @@ bool e820_get_entry(int idx, uint32_t type, uint64_t *address, uint64_t *length) static uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcms, unsigned int cpu_index) { + MachineState *ms = MACHINE(pcms); PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); uint32_t correct_id; static bool warned; - correct_id = x86_apicid_from_cpu_idx(smp_cores, smp_threads, cpu_index); + correct_id = x86_apicid_from_cpu_idx(ms->smp.cores, + ms->smp.threads, cpu_index); if (pcmc->compat_apic_id_mode) { if (cpu_index != correct_id && !warned && !qtest_enabled()) { error_report("APIC IDs set in compatibility mode, " @@ -1565,9 +1567,10 @@ void pc_cpus_init(PCMachineState *pcms) * * This is used for FW_CFG_MAX_CPUS. See comments on bochs_bios_init(). */ - pcms->apic_id_limit = x86_cpu_apic_id_from_index(pcms, max_cpus - 1) + 1; + pcms->apic_id_limit = x86_cpu_apic_id_from_index(pcms, + ms->smp.max_cpus - 1) + 1; possible_cpus = mc->possible_cpu_arch_ids(ms); - for (i = 0; i < smp_cpus; i++) { + for (i = 0; i < ms->smp.cpus; i++) { pc_new_cpu(possible_cpus->cpus[i].type, possible_cpus->cpus[i].arch_id, &error_fatal); } @@ -2291,6 +2294,8 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, X86CPU *cpu = X86_CPU(dev); MachineState *ms = MACHINE(hotplug_dev); PCMachineState *pcms = PC_MACHINE(hotplug_dev); + unsigned int smp_cores = ms->smp.cores; + unsigned int smp_threads = ms->smp.threads; if(!object_dynamic_cast(OBJECT(cpu), ms->cpu_type)) { error_setg(errp, "Invalid CPU type, expected cpu type: '%s'", @@ -2300,7 +2305,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, /* if APIC ID is not set, set it based on socket/core/thread properties */ if (cpu->apic_id == UNASSIGNED_APIC_ID) { - int max_socket = (max_cpus - 1) / smp_threads / smp_cores; + int max_socket = (ms->smp.max_cpus - 1) / smp_threads / smp_cores; if (cpu->socket_id < 0) { error_setg(errp, "CPU socket-id is not set"); @@ -2718,7 +2723,7 @@ static int64_t pc_get_default_cpu_node_id(const MachineState *ms, int idx) assert(idx < ms->possible_cpus->len); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, - smp_cores, smp_threads, &topo); + ms->smp.cores, ms->smp.threads, &topo); return topo.pkg_id % nb_numa_nodes; } @@ -2726,6 +2731,7 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *ms) { PCMachineState *pcms = PC_MACHINE(ms); int i; + unsigned int max_cpus = ms->smp.max_cpus; if (ms->possible_cpus) { /* @@ -2746,7 +2752,7 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *ms) ms->possible_cpus->cpus[i].vcpus_count = 1; ms->possible_cpus->cpus[i].arch_id = x86_cpu_apic_id_from_index(pcms, i); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, - smp_cores, smp_threads, &topo); + ms->smp.cores, ms->smp.threads, &topo); ms->possible_cpus->cpus[i].props.has_socket_id = true; ms->possible_cpus->cpus[i].props.socket_id = topo.pkg_id; ms->possible_cpus->cpus[i].props.has_core_id = true; |