qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org, "Gleb Natapov" <gleb@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Marcelo Tosatti" <mtosatti@redhat.com>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [RFC 04/12] kvm: Create kvm_arch_vcpu_id() function
Date: Wed,  9 Jan 2013 16:53:44 -0200	[thread overview]
Message-ID: <1357757632-1950-5-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1357757632-1950-1-git-send-email-ehabkost@redhat.com>

This will allow each architecture to define how the VCPU ID is set on
the KVM_CREATE_VCPU ioctl call.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: kvm@vger.kernel.org
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>

Changes v2:
 - Get CPUState as argument instead of CPUArchState
---
 include/sysemu/kvm.h | 3 +++
 kvm-all.c            | 2 +-
 target-i386/kvm.c    | 5 +++++
 target-ppc/kvm.c     | 5 +++++
 target-s390x/kvm.c   | 5 +++++
 5 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 22acf91..384ee66 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -196,6 +196,9 @@ int kvm_arch_init(KVMState *s);
 
 int kvm_arch_init_vcpu(CPUState *cpu);
 
+/* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */
+unsigned long kvm_arch_vcpu_id(CPUState *cpu);
+
 void kvm_arch_reset_vcpu(CPUState *cpu);
 
 int kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr);
diff --git a/kvm-all.c b/kvm-all.c
index 6e2164b..d37359f 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -222,7 +222,7 @@ int kvm_init_vcpu(CPUState *cpu)
 
     DPRINTF("kvm_init_vcpu\n");
 
-    ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, cpu->cpu_index);
+    ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, kvm_arch_vcpu_id(cpu));
     if (ret < 0) {
         DPRINTF("kvm_create_vcpu failed\n");
         goto err;
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 3acff40..5f3f789 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -411,6 +411,11 @@ static void cpu_update_state(void *opaque, int running, RunState state)
     }
 }
 
+unsigned long kvm_arch_vcpu_id(CPUState *cpu)
+{
+    return cpu->cpu_index;
+}
+
 int kvm_arch_init_vcpu(CPUState *cs)
 {
     struct {
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index e4a387f..bdcd133 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -384,6 +384,11 @@ static inline void kvm_fixup_page_sizes(PowerPCCPU *cpu)
 
 #endif /* !defined (TARGET_PPC64) */
 
+unsigned long kvm_arch_vcpu_id(CPUState *cpu)
+{
+    return cpu->cpu_index;
+}
+
 int kvm_arch_init_vcpu(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 6ec5e6d..bd9864c 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -72,6 +72,11 @@ int kvm_arch_init(KVMState *s)
     return 0;
 }
 
+unsigned long kvm_arch_vcpu_id(CPUState *cpu)
+{
+    return cpu->cpu_index;
+}
+
 int kvm_arch_init_vcpu(CPUState *cpu)
 {
     int ret = 0;
-- 
1.7.11.7

  parent reply	other threads:[~2013-01-09 18:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-09 18:53 [Qemu-devel] [RFC 00/12] target-i386: Fix APIC-ID-based topology (v4) Eduardo Habkost
2013-01-09 18:53 ` [Qemu-devel] [RFC 01/12] kvm: add KVM_FEATURE_CLOCKSOURCE_STABLE_BIT fake #define Eduardo Habkost
2013-01-10 23:15   ` Igor Mammedov
2013-01-11  0:05     ` Eduardo Habkost
2013-01-09 18:53 ` [Qemu-devel] [RFC 02/12] target-i386: Don't set any KVM flag by default if KVM is disabled Eduardo Habkost
2013-01-10 11:47   ` Michael S. Tsirkin
2013-01-10 23:07   ` Igor Mammedov
2013-01-11  0:03     ` Eduardo Habkost
2013-01-09 18:53 ` [Qemu-devel] [RFC 03/12] pc: Reverse pc_init_pci() compatibility logic Eduardo Habkost
2013-01-09 18:53 ` Eduardo Habkost [this message]
2013-01-09 18:53 ` [Qemu-devel] [RFC 05/12] target-i386: kvm: Set vcpu_id to APIC ID instead of CPU index Eduardo Habkost
2013-01-09 18:53 ` [Qemu-devel] [RFC 06/12] fw_cfg: Remove FW_CFG_MAX_CPUS from fw_cfg_init() Eduardo Habkost
2013-01-09 18:53 ` [Qemu-devel] [RFC 07/12] target-i386/cpu: Introduce apic_id_for_cpu() function Eduardo Habkost
2013-01-10 23:31   ` Igor Mammedov
2013-01-10 23:51     ` Eduardo Habkost
2013-01-10 23:57     ` Eduardo Habkost
2013-01-09 18:53 ` [Qemu-devel] [RFC 08/12] cpus.h: Make constant smp_cores/smp_threads available on *-user Eduardo Habkost
2013-01-09 18:53 ` [Qemu-devel] [RFC 09/12] pc: Set fw_cfg data based on APIC ID calculation Eduardo Habkost
2013-01-09 18:53 ` [Qemu-devel] [RFC 10/12] tests: Support target-specific unit tests Eduardo Habkost
2013-01-09 18:53 ` [Qemu-devel] [RFC 11/12] target-i386: Topology & APIC ID utility functions Eduardo Habkost
2013-01-09 18:53 ` [Qemu-devel] [RFC 12/12] pc: Generate APIC IDs according to CPU topology Eduardo Habkost
2013-01-10 23:36   ` Igor Mammedov
2013-01-10 23:55     ` Eduardo Habkost
2013-01-17 18:29 ` [Qemu-devel] [RFC 00/12] target-i386: Fix APIC-ID-based topology (v4) Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1357757632-1950-5-git-send-email-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=afaerber@suse.de \
    --cc=gleb@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).