From a14094de7a4f4d7ccbfd104ee857584b73fb7f3e Mon Sep 17 00:00:00 2001
Message-Id: <a14094de7a4f4d7ccbfd104ee857584b73fb7f3e.1351776104.git.minovotn@redhat.com>
In-Reply-To: <383c464e74b19af5a4e1e18bb56df969e9d61c2a.1351776104.git.minovotn@redhat.com>
References: <383c464e74b19af5a4e1e18bb56df969e9d61c2a.1351776104.git.minovotn@redhat.com>
From: Eduardo Habkost <ehabkost@redhat.com>
Date: Mon, 29 Oct 2012 18:52:29 +0100
Subject: [PATCH 03/11] target-i386: kvm: set vcpu_id to APIC ID instead of
 CPU index

RH-Author: Eduardo Habkost <ehabkost@redhat.com>
Message-id: <1351536756-16475-4-git-send-email-ehabkost@redhat.com>
Patchwork-id: 43761
O-Subject: [RHEL6.4 qemu-kvm PATCH 03/10] target-i386: kvm: set vcpu_id to APIC ID instead of CPU index
Bugzilla: 733720
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
RH-Acked-by: Gleb Natapov <gleb@redhat.com>

Bugzilla: 733720
Related TestOnly BZs: 816804, 815958, 782648
Upstream status: submitted
 Message-Id: <1351101001-14589-7-git-send-email-ehabkost@redhat.com
 http://article.gmane.org/gmane.comp.emulators.qemu/177690

The CPU ID in KVM is supposed to be the APIC ID, so change the
KVM_CREATE_VCPU call to match it. The current behavior didn't break
anything yet because today the APIC ID is assumed to be == the CPU
index, but this won't be true in the future.

[RHEL note: this patch touches qemu-kvm-x86.c instead of
 target-i386/kvm.c, as the upstream KVM initialization code is very
 different, now]

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu-kvm-x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 qemu-kvm-x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 3fdd6fe..b09f427 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -1387,7 +1387,7 @@ static void cpu_update_state(void *opaque, int running, RunState state)
 
 unsigned long kvm_arch_vcpu_id(CPUArchState *env)
 {
-    return env->cpu_index;
+    return env->cpuid_apic_id;
 }
 
 int kvm_arch_init_vcpu(CPUState *cenv)
-- 
1.7.11.7

