Patchwork [1,of,2] kvm: Move KVM mp_state accessors to i386-specific code

login
register
mail settings
Submitter Hollis Blanchard
Date Nov. 9, 2009, 9:05 p.m.
Message ID <204026d59328febd9789.1257800737@localhost.localdomain>
Download mbox | patch
Permalink /patch/38031/
State New
Headers show

Comments

Hollis Blanchard - Nov. 9, 2009, 9:05 p.m.
Unbreaks PowerPC and S390 KVM builds.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Jan Kiszka - Nov. 9, 2009, 10:12 p.m.
Hollis Blanchard wrote:
> Unbreaks PowerPC and S390 KVM builds.

What breaks precisely?

Note that KVM_GET/SET_MP_STATE are generic IOCTLs and supposed to be
shared with ia64 - one day. We could still move things back then, but
maybe we can handle the build issues already in place, specifically as
qemu-kvm is carrying this in generic code since ages.

Jan

> 
> Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
> 
> diff --git a/kvm-all.c b/kvm-all.c
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -207,26 +207,6 @@ err:
>      return ret;
>  }
>  
> -int kvm_put_mp_state(CPUState *env)
> -{
> -    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
> -
> -    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
> -}
> -
> -int kvm_get_mp_state(CPUState *env)
> -{
> -    struct kvm_mp_state mp_state;
> -    int ret;
> -
> -    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
> -    if (ret < 0) {
> -        return ret;
> -    }
> -    env->mp_state = mp_state.mp_state;
> -    return 0;
> -}
> -
>  /*
>   * dirty pages logging control
>   */
> diff --git a/kvm.h b/kvm.h
> --- a/kvm.h
> +++ b/kvm.h
> @@ -74,9 +74,6 @@ int kvm_vm_ioctl(KVMState *s, int type, 
>  
>  int kvm_vcpu_ioctl(CPUState *env, int type, ...);
>  
> -int kvm_get_mp_state(CPUState *env);
> -int kvm_put_mp_state(CPUState *env);
> -
>  /* Arch specific hooks */
>  
>  int kvm_arch_post_run(CPUState *env, struct kvm_run *run);
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -659,6 +659,26 @@ static int kvm_get_msrs(CPUState *env)
>      return 0;
>  }
>  
> +static int kvm_put_mp_state(CPUState *env)
> +{
> +    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
> +
> +    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
> +}
> +
> +static int kvm_get_mp_state(CPUState *env)
> +{
> +    struct kvm_mp_state mp_state;
> +    int ret;
> +
> +    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
> +    if (ret < 0) {
> +        return ret;
> +    }
> +    env->mp_state = mp_state.mp_state;
> +    return 0;
> +}
> +
>  int kvm_arch_put_registers(CPUState *env)
>  {
>      int ret;
Jan Kiszka - Nov. 9, 2009, 11:03 p.m.
Hollis Blanchard wrote:
> This is the technique Anthony requested this morning, rather than
> relocating mp_state.

Then let's move it. There is not that much code to share anyway.

> To be honest, I don't care which way it's fixed;
> this is at least the 3rd patch to solve this seemingly trivial
> problem.

That's indeed unfortunate, but I think to remember that not all of these
attempts were clean.

Jan

> 
> /home/hollisb/source/qemu-fresh.hg/kvm-all.c: In function 'kvm_put_mp_state':
> /home/hollisb/source/qemu-fresh.hg/kvm-all.c:212: error: 'struct
> CPUPPCState' has no member named 'mp_state'
> 
> -Hollis
> 
> On Mon, Nov 9, 2009 at 2:12 PM, Jan Kiszka <jan.kiszka@web.de> wrote:
>> Hollis Blanchard wrote:
>>> Unbreaks PowerPC and S390 KVM builds.
>> What breaks precisely?
>>
>> Note that KVM_GET/SET_MP_STATE are generic IOCTLs and supposed to be
>> shared with ia64 - one day. We could still move things back then, but
>> maybe we can handle the build issues already in place, specifically as
>> qemu-kvm is carrying this in generic code since ages.
>>
>> Jan
>>
>>> Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
>>>
>>> diff --git a/kvm-all.c b/kvm-all.c
>>> --- a/kvm-all.c
>>> +++ b/kvm-all.c
>>> @@ -207,26 +207,6 @@ err:
>>>      return ret;
>>>  }
>>>
>>> -int kvm_put_mp_state(CPUState *env)
>>> -{
>>> -    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
>>> -
>>> -    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
>>> -}
>>> -
>>> -int kvm_get_mp_state(CPUState *env)
>>> -{
>>> -    struct kvm_mp_state mp_state;
>>> -    int ret;
>>> -
>>> -    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
>>> -    if (ret < 0) {
>>> -        return ret;
>>> -    }
>>> -    env->mp_state = mp_state.mp_state;
>>> -    return 0;
>>> -}
>>> -
>>>  /*
>>>   * dirty pages logging control
>>>   */
>>> diff --git a/kvm.h b/kvm.h
>>> --- a/kvm.h
>>> +++ b/kvm.h
>>> @@ -74,9 +74,6 @@ int kvm_vm_ioctl(KVMState *s, int type,
>>>
>>>  int kvm_vcpu_ioctl(CPUState *env, int type, ...);
>>>
>>> -int kvm_get_mp_state(CPUState *env);
>>> -int kvm_put_mp_state(CPUState *env);
>>> -
>>>  /* Arch specific hooks */
>>>
>>>  int kvm_arch_post_run(CPUState *env, struct kvm_run *run);
>>> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
>>> --- a/target-i386/kvm.c
>>> +++ b/target-i386/kvm.c
>>> @@ -659,6 +659,26 @@ static int kvm_get_msrs(CPUState *env)
>>>      return 0;
>>>  }
>>>
>>> +static int kvm_put_mp_state(CPUState *env)
>>> +{
>>> +    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
>>> +
>>> +    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
>>> +}
>>> +
>>> +static int kvm_get_mp_state(CPUState *env)
>>> +{
>>> +    struct kvm_mp_state mp_state;
>>> +    int ret;
>>> +
>>> +    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
>>> +    if (ret < 0) {
>>> +        return ret;
>>> +    }
>>> +    env->mp_state = mp_state.mp_state;
>>> +    return 0;
>>> +}
>>> +
>>>  int kvm_arch_put_registers(CPUState *env)
>>>  {
>>>      int ret;
>>
>>

Patch

diff --git a/kvm-all.c b/kvm-all.c
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -207,26 +207,6 @@  err:
     return ret;
 }
 
-int kvm_put_mp_state(CPUState *env)
-{
-    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
-
-    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
-}
-
-int kvm_get_mp_state(CPUState *env)
-{
-    struct kvm_mp_state mp_state;
-    int ret;
-
-    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
-    if (ret < 0) {
-        return ret;
-    }
-    env->mp_state = mp_state.mp_state;
-    return 0;
-}
-
 /*
  * dirty pages logging control
  */
diff --git a/kvm.h b/kvm.h
--- a/kvm.h
+++ b/kvm.h
@@ -74,9 +74,6 @@  int kvm_vm_ioctl(KVMState *s, int type, 
 
 int kvm_vcpu_ioctl(CPUState *env, int type, ...);
 
-int kvm_get_mp_state(CPUState *env);
-int kvm_put_mp_state(CPUState *env);
-
 /* Arch specific hooks */
 
 int kvm_arch_post_run(CPUState *env, struct kvm_run *run);
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -659,6 +659,26 @@  static int kvm_get_msrs(CPUState *env)
     return 0;
 }
 
+static int kvm_put_mp_state(CPUState *env)
+{
+    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
+
+    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
+}
+
+static int kvm_get_mp_state(CPUState *env)
+{
+    struct kvm_mp_state mp_state;
+    int ret;
+
+    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
+    if (ret < 0) {
+        return ret;
+    }
+    env->mp_state = mp_state.mp_state;
+    return 0;
+}
+
 int kvm_arch_put_registers(CPUState *env)
 {
     int ret;