Patchwork [RFC,07/18] kvm: create kvm_arch_vcpu_id() function

login
register
mail settings
Submitter Eduardo Habkost
Date Oct. 3, 2012, 1:29 p.m.
Message ID <1349270954-4657-8-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/188775/
State New
Headers show

Comments

Eduardo Habkost - Oct. 3, 2012, 1:29 p.m.
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>
---
 kvm-all.c          | 2 +-
 kvm.h              | 3 +++
 target-i386/kvm.c  | 5 +++++
 target-ppc/kvm.c   | 5 +++++
 target-s390x/kvm.c | 5 +++++
 5 files changed, 19 insertions(+), 1 deletion(-)

Patch

diff --git a/kvm-all.c b/kvm-all.c
index 92a7137..2fb2596 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -222,7 +222,7 @@  int kvm_init_vcpu(CPUArchState *env)
 
     DPRINTF("kvm_init_vcpu\n");
 
-    ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, env->cpu_index);
+    ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, kvm_arch_vcpu_id(env));
     if (ret < 0) {
         DPRINTF("kvm_create_vcpu failed\n");
         goto err;
diff --git a/kvm.h b/kvm.h
index dea2998..e88058f 100644
--- a/kvm.h
+++ b/kvm.h
@@ -181,6 +181,9 @@  int kvm_arch_init(KVMState *s);
 
 int kvm_arch_init_vcpu(CPUArchState *env);
 
+/* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */
+unsigned long kvm_arch_vcpu_id(CPUArchState *env);
+
 void kvm_arch_reset_vcpu(CPUArchState *env);
 
 int kvm_arch_on_sigbus_vcpu(CPUArchState *env, int code, void *addr);
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index ce8678d..bb972d8 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -353,6 +353,11 @@  static void cpu_update_state(void *opaque, int running, RunState state)
     }
 }
 
+unsigned long kvm_arch_vcpu_id(CPUArchState *env)
+{
+    return env->cpu_index;
+}
+
 int kvm_arch_init_vcpu(CPUX86State *env)
 {
     struct {
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index a31d278..e74a189 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -371,6 +371,11 @@  static inline void kvm_fixup_page_sizes(CPUPPCState *env)
 
 #endif /* !defined (TARGET_PPC64) */
 
+unsigned long kvm_arch_vcpu_id(CPUArchState *env)
+{
+    return env->cpu_index;
+}
+
 int kvm_arch_init_vcpu(CPUPPCState *cenv)
 {
     int ret;
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 07edf93..9e4c6c6 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(CPUArchState *env)
+{
+    return env->cpu_index;
+}
+
 int kvm_arch_init_vcpu(CPUS390XState *env)
 {
     int ret = 0;