Patchwork [01/12] target-i386: consolidate error propagation in x86_cpu_realizefn()

login
register
mail settings
Submitter Igor Mammedov
Date March 21, 2013, 2:28 p.m.
Message ID <1363876125-8264-2-git-send-email-imammedo@redhat.com>
Download mbox | patch
Permalink /patch/229705/
State New
Headers show

Comments

Igor Mammedov - March 21, 2013, 2:28 p.m.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
Paolo Bonzini - March 27, 2013, 10:21 a.m.
Il 21/03/2013 15:28, Igor Mammedov ha scritto:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  target-i386/cpu.c |   17 ++++++++++-------
>  1 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index a0640db..e905bcf 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -2100,9 +2100,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
>      X86CPU *cpu = X86_CPU(dev);
>      X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
>      CPUX86State *env = &cpu->env;
> -#ifndef CONFIG_USER_ONLY
>      Error *local_err = NULL;
> -#endif
>  
>      if (env->cpuid_7_0_ebx_features && env->cpuid_level < 7) {
>          env->cpuid_level = 7;
> @@ -2135,8 +2133,9 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
>  #endif
>          if (check_cpuid && kvm_check_features_against_host(cpu)
>              && enforce_cpuid) {
> -            error_setg(errp, "Host's CPU doesn't support requested features");
> -            return;
> +            error_setg(&local_err,
> +                       "Host's CPU doesn't support requested features");
> +            goto out;
>          }
>      }
>  
> @@ -2146,8 +2145,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
>      if (cpu->env.cpuid_features & CPUID_APIC || smp_cpus > 1) {
>          x86_cpu_apic_init(cpu, &local_err);
>          if (local_err != NULL) {
> -            error_propagate(errp, local_err);
> -            return;
> +            goto out;
>          }
>      }
>  #endif
> @@ -2156,7 +2154,12 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
>      qemu_init_vcpu(&cpu->env);
>      cpu_reset(CPU(cpu));
>  
> -    xcc->parent_realize(dev, errp);
> +    xcc->parent_realize(dev, &local_err);
> +out:
> +    if (local_err != NULL) {
> +        error_propagate(errp, local_err);
> +        return;
> +    }
>  }
>  
>  /* Enables contiguous-apic-ID mode, for compatibility */
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Eduardo Habkost - April 1, 2013, 8 p.m.
On Thu, Mar 21, 2013 at 03:28:34PM +0100, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

> ---
>  target-i386/cpu.c |   17 ++++++++++-------
>  1 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index a0640db..e905bcf 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -2100,9 +2100,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
>      X86CPU *cpu = X86_CPU(dev);
>      X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
>      CPUX86State *env = &cpu->env;
> -#ifndef CONFIG_USER_ONLY
>      Error *local_err = NULL;
> -#endif
>  
>      if (env->cpuid_7_0_ebx_features && env->cpuid_level < 7) {
>          env->cpuid_level = 7;
> @@ -2135,8 +2133,9 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
>  #endif
>          if (check_cpuid && kvm_check_features_against_host(cpu)
>              && enforce_cpuid) {
> -            error_setg(errp, "Host's CPU doesn't support requested features");
> -            return;
> +            error_setg(&local_err,
> +                       "Host's CPU doesn't support requested features");
> +            goto out;
>          }
>      }
>  
> @@ -2146,8 +2145,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
>      if (cpu->env.cpuid_features & CPUID_APIC || smp_cpus > 1) {
>          x86_cpu_apic_init(cpu, &local_err);
>          if (local_err != NULL) {
> -            error_propagate(errp, local_err);
> -            return;
> +            goto out;
>          }
>      }
>  #endif
> @@ -2156,7 +2154,12 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
>      qemu_init_vcpu(&cpu->env);
>      cpu_reset(CPU(cpu));
>  
> -    xcc->parent_realize(dev, errp);
> +    xcc->parent_realize(dev, &local_err);
> +out:
> +    if (local_err != NULL) {
> +        error_propagate(errp, local_err);
> +        return;
> +    }
>  }
>  
>  /* Enables contiguous-apic-ID mode, for compatibility */
> -- 
> 1.7.1
> 
>

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index a0640db..e905bcf 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2100,9 +2100,7 @@  static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
     X86CPU *cpu = X86_CPU(dev);
     X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
     CPUX86State *env = &cpu->env;
-#ifndef CONFIG_USER_ONLY
     Error *local_err = NULL;
-#endif
 
     if (env->cpuid_7_0_ebx_features && env->cpuid_level < 7) {
         env->cpuid_level = 7;
@@ -2135,8 +2133,9 @@  static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
 #endif
         if (check_cpuid && kvm_check_features_against_host(cpu)
             && enforce_cpuid) {
-            error_setg(errp, "Host's CPU doesn't support requested features");
-            return;
+            error_setg(&local_err,
+                       "Host's CPU doesn't support requested features");
+            goto out;
         }
     }
 
@@ -2146,8 +2145,7 @@  static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
     if (cpu->env.cpuid_features & CPUID_APIC || smp_cpus > 1) {
         x86_cpu_apic_init(cpu, &local_err);
         if (local_err != NULL) {
-            error_propagate(errp, local_err);
-            return;
+            goto out;
         }
     }
 #endif
@@ -2156,7 +2154,12 @@  static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
     qemu_init_vcpu(&cpu->env);
     cpu_reset(CPU(cpu));
 
-    xcc->parent_realize(dev, errp);
+    xcc->parent_realize(dev, &local_err);
+out:
+    if (local_err != NULL) {
+        error_propagate(errp, local_err);
+        return;
+    }
 }
 
 /* Enables contiguous-apic-ID mode, for compatibility */