[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH v2 1/1] ppc: spapr: Make VCPU ID handling private
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [PATCH v2 1/1] ppc: spapr: Make VCPU ID handling private to SPAPR |
Date: |
Tue, 8 Aug 2017 16:24:01 +1000 |
User-agent: |
Mutt/1.8.3 (2017-05-23) |
On Mon, Aug 07, 2017 at 04:33:29PM +1000, Sam Bobroff wrote:
> The concept of a VCPU ID that differs from the CPU's index
> (cpu->cpu_index) exists only within SPAPR machines so, move the
> functions ppc_get_vcpu_id() and ppc_get_cpu_by_vcpu_id() into spapr.c
> and rename them appropriately.
>
> Signed-off-by: Sam Bobroff <address@hidden>
> ---
> Changes in v2:
>
> * Re-arranged so that spapr_vcpu_id() calls kvm_arch_vcpu_id() rather than the
> other way around.
Ah.. so close..
[snip]
> +int spapr_vcpu_id(PowerPCCPU *cpu)
> +{
> + CPUState *cs = CPU(cpu);
> +
> + if (kvm_enabled()) {
> + return kvm_arch_vcpu_id(cs);
> + } else {
> + return cs->cpu_index;
> + }
> +}
> +
> +PowerPCCPU *spapr_find_cpu(int vcpu_id)
> +{
> + CPUState *cs;
> +
> + CPU_FOREACH(cs) {
> + PowerPCCPU *cpu = POWERPC_CPU(cs);
> +
> + if (cpu->vcpu_id == vcpu_id) {
This is still reaching into vcpu_id which should really be cpu
private, not in spapr. You can use spapr_vcpu_id() which you already
defined to avoid this.
With that done, I believe it should be possible to put cpu->vcpu_id in
an ifdef CONFIG_KVM and have things work.
> + return cpu;
> + }
> + }
> +
> + return NULL;
> +}
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature