* Paolo Bonzini (pbonz...@redhat.com) wrote:
> Avoid further code duplication in the next patch.
> 
> Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
> ---
>  target-i386/kvm.c | 22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index f1ad805..38609fd 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -1532,6 +1532,16 @@ static void kvm_msr_entry_add(X86CPU *cpu, uint32_t 
> index, uint64_t value)
>      msrs->nmsrs++;
>  }
>  
> +static int kvm_put_one_msr(X86CPU *cpu, int index, uint64_t value)
> +{
> +    int ret;

^^^ Unused.

> +    kvm_msr_buf_reset(cpu);
> +    kvm_msr_entry_add(cpu, index, value);
> +
> +    return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, cpu->kvm_msr_buf);

Dave

> +}
> +
>  static int kvm_put_tscdeadline_msr(X86CPU *cpu)
>  {
>      CPUX86State *env = &cpu->env;
> @@ -1541,10 +1551,7 @@ static int kvm_put_tscdeadline_msr(X86CPU *cpu)
>          return 0;
>      }
>  
> -    kvm_msr_buf_reset(cpu);
> -    kvm_msr_entry_add(cpu, MSR_IA32_TSCDEADLINE, env->tsc_deadline);
> -
> -    ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, cpu->kvm_msr_buf);
> +    ret = kvm_put_one_msr(cpu, MSR_IA32_TSCDEADLINE, env->tsc_deadline);
>      if (ret < 0) {
>          return ret;
>      }
> @@ -1567,11 +1574,8 @@ static int kvm_put_msr_feature_control(X86CPU *cpu)
>          return 0;
>      }
>  
> -    kvm_msr_buf_reset(cpu);
> -    kvm_msr_entry_add(cpu, MSR_IA32_FEATURE_CONTROL,
> -                      cpu->env.msr_ia32_feature_control);
> -
> -    ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, cpu->kvm_msr_buf);
> +    ret = kvm_put_one_msr(cpu, MSR_IA32_FEATURE_CONTROL,
> +                          cpu->env.msr_ia32_feature_control);
>      if (ret < 0) {
>          return ret;
>      }
> -- 
> 2.7.4
> 
> 
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK

Reply via email to