kvm: Create kvm_arch_vcpu_id() function
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/9 kvm: Create kvm_arch_vcpu_id() function
This will allow each architecture to define how the VCPU ID is set on the KVM_CREATE_VCPU ioctl call.
---
Cc: [email protected]
Cc: Michael S. Tsirkin <[email protected]>
Cc: Gleb Natapov <[email protected]>
Cc: Marcelo Tosatti <[email protected]>
Changes v2:
- Get CPUState as argument instead of CPUArchState
Changes v3:
- Convert KVM_CREATE_VCPU ioctl() argument to void*, so the argument type matches the type expected by kvm_vm_ioctl()
--- 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(-)
include/sysemu/kvm.h +3 -0
@@ -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);
kvm-all.c +1 -1
@@ -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 , (void *)kvm_arch_vcpu_id (cpu));if (ret <0 ) {DPRINTF ("kvm_create_vcpu failed\n" ); goto err;
target-i386/kvm.c +5 -0
@@ -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 {
target-ppc/kvm.c +5 -0
@@ -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);
target-s390x/kvm.c +5 -0
@@ -76,6 +76,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 ;
Signature · 1 line
1.8.1
Quoted 4 lines · Eduardo Habkost
This will allow each architecture to define how the VCPU ID is set on the
KVM_CREATE_VCPUioctl call.Signed-off-by Eduardo Habkost <[email protected]>
Quoted 97 lines
---
Cc: [email protected]
Cc: Michael S. Tsirkin <[email protected]>
Cc: Gleb Natapov <[email protected]>
Cc: Marcelo Tosatti <[email protected]>Changes v2:
- Get CPUState as argument instead of CPUArchStateChanges v3:
- ConvertKVM_CREATE_VCPUioctl()argument to void*, so the argument type matches the type expected bykvm_vm_ioctl()--- 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(-)include/sysemu/kvm.h +3
-0@@ -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);kvm-all.c +1
-1@@ -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 , (void *)kvm_arch_vcpu_id (cpu));if (ret <0 ) {DPRINTF ("kvm_create_vcpu failed\n" ); goto err;target-i386/kvm.c +5
-0@@ -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 {target-ppc/kvm.c +5
-0@@ -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);target-s390x/kvm.c +5
-0@@ -76,6 +76,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 ;Signature · 1 line
1.8.1
--
Gleb.
PATCH 2/9 target-i386: kvm: Set vcpu_id to APIC ID instead of CPU index
In reply to a message not in the archiveThe 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 equal to the CPU index, but this won't be true in the future.
---
Cc: [email protected]
Cc: Michael S. Tsirkin <[email protected]>
Cc: Gleb Natapov <[email protected]>
Cc: Marcelo Tosatti <[email protected]>
Changes v2:
- Change only i386 code (kvm_arch_vcpu_id())
Changes v3:
- Get CPUState as argument instead of CPUArchState
--- target-i386/kvm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
target-i386/kvm.c +3 -2
@@ -411,9 +411,10 @@ static void cpu_update_state(void *opaque, int running, RunState state) } } -unsigned long kvm_arch_vcpu_id (CPUState *cpu) +unsigned long kvm_arch_vcpu_id (CPUState *cs) { -return cpu->cpu_index; +X86CPU *cpu =X86_CPU (cs); +return cpu->env.cpuid_apic_id; }int kvm_arch_init_vcpu (CPUState *cs)
Signature · 1 line
1.8.1
Re: [PATCH for-1.4 qom-cpu 2/9] target-i386: kvm: Set vcpu_id to APIC ID instead of CPU index
Quoted 7 lines · Eduardo Habkost
The CPU ID in KVM is supposed to be the APIC ID, so change the
KVM_CREATE_VCPUcall to match it. The current behavior didn't break anything yet because today the APIC ID is assumed to be equal to the CPU index, but this won't be true in the future.Signed-off-by Eduardo Habkost <[email protected]>Reviewed-by Marcelo Tosatti <[email protected]>
Quoted 34 lines
---
Cc: [email protected]
Cc: Michael S. Tsirkin <[email protected]>
Cc: Gleb Natapov <[email protected]>
Cc: Marcelo Tosatti <[email protected]>Changes v2:
- Change only i386 code (kvm_arch_vcpu_id())Changes v3:
- Get CPUState as argument instead of CPUArchState--- target-i386/kvm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)target-i386/kvm.c +3
-2@@ -411,9 +411,10 @@ static void cpu_update_state(void *opaque, int running, RunState state) } } -unsigned long kvm_arch_vcpu_id (CPUState *cpu) +unsigned long kvm_arch_vcpu_id (CPUState *cs) { -return cpu->cpu_index; +X86CPU *cpu =X86_CPU (cs); +return cpu->env.cpuid_apic_id; }int kvm_arch_init_vcpu (CPUState *cs)Signature · 1 line
1.8.1
--
Gleb.
Andreas Färber
AppliedRe: [Qemu-devel] [PATCH for-1.4 qom-cpu 2/9] target-i386: kvm: Set vcpu_id to APIC ID instead of CPU index
Am 23.01.2013 11:26, schrieb Gleb Natapov:
Quoted 9 lines · Eduardo Habkost
Quoted 7 lines
The CPU ID in KVM is supposed to be the APIC ID, so change the
KVM_CREATE_VCPUcall to match it. The current behavior didn't break anything yet because today the APIC ID is assumed to be equal to the CPU index, but this won't be true in the future.Signed-off-by Eduardo Habkost <[email protected]>Reviewed-by Marcelo Tosatti <[email protected]>Acked-by Gleb Natapov <[email protected]>
Thanks, applied these two to qom-cpu already:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg