From f03419ada4037556d6e6a1f333a07e5d7a719f8c Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: <383c464e74b19af5a4e1e18bb56df969e9d61c2a.1351776104.git.minovotn@redhat.com> References: <383c464e74b19af5a4e1e18bb56df969e9d61c2a.1351776104.git.minovotn@redhat.com> From: Eduardo Habkost Date: Mon, 29 Oct 2012 18:52:33 +0100 Subject: [PATCH 07/11] CPU hotplug: use apic_id_for_cpu() RH-Author: Eduardo Habkost Message-id: <1351536756-16475-8-git-send-email-ehabkost@redhat.com> Patchwork-id: 43755 O-Subject: [RHEL6.4 qemu-kvm PATCH 07/10] CPU hotplug: use apic_id_for_cpu() Bugzilla: 733720 RH-Acked-by: Laszlo Ersek RH-Acked-by: Igor Mammedov RH-Acked-by: Gleb Natapov Bugzilla: 733720 Related TestOnly BZs: 816804, 815958, 782648 Upstream status: not applicable (upstream doesn't support CPU hotplug yet) The CPU hotplug tables are based on APIC ID, not "CPU index", so use apic_id_for_cpu() when enabling/disabling CPUs on the CPU hotplug code. Signed-off-by: Eduardo Habkost --- hw/acpi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) Signed-off-by: Michal Novotny --- hw/acpi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/acpi.c b/hw/acpi.c index cf7dc00..f824b8e 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -978,6 +978,7 @@ static void disable_processor(struct gpe_regs *g, int cpu) void qemu_system_cpu_hot_add(int cpu, int state, Monitor *mon) { CPUState *env; + uint32_t apic_id; if ((cpu < 1) || (cpu > max_cpus - 1)) { monitor_printf(mon, "cpu id[%d] must be in range [1..%d]\n", @@ -985,19 +986,20 @@ void qemu_system_cpu_hot_add(int cpu, int state, Monitor *mon) return; } + apic_id = apic_id_for_cpu(cpu); if (state && !qemu_get_cpu(cpu)) { env = pc_new_cpu(model); if (!env) { monitor_printf(mon, "cpu %d creation failed\n", cpu); return; } - env->cpuid_apic_id = cpu; + env->cpuid_apic_id = apic_id; } if (state) - enable_processor(&pm_state->gpe, cpu); + enable_processor(&pm_state->gpe, apic_id); else - disable_processor(&pm_state->gpe, cpu); + disable_processor(&pm_state->gpe, apic_id); /* update number of cpus in cmos, to allow BIOS see it on reboot */ rtc_set_memory(rtc_state, 0x5f, acpi_online_cpu_count() - 1); -- 1.7.11.7