qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v6 04/11] cpu: Don't realize CPU from cpu_generi


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH v6 04/11] cpu: Don't realize CPU from cpu_generic_init()
Date: Sat, 23 Jan 2016 11:31:44 -0200
User-agent: Mutt/1.5.23 (2014-03-12)

On Fri, Jan 08, 2016 at 12:25:12PM +0530, Bharata B Rao wrote:
> Don't do CPU realization from cpu_generic_init(). With this
> cpu_generic_init() will be used to just create CPU threads and they
> should be realized separately from realizefn call.
> 
> Convert the existing callers to do explicit realization.
> 
> Signed-off-by: Bharata B Rao <address@hidden>

Reviewed-by: Eduardo Habkost <address@hidden>

Reviewed by comparing the patch with the results of the
following Coccinelle patch:

@@
typedef CPUState;
identifier cc, cpu, err;
@@
 CPUState *cpu_generic_init(...)
 {
     ...
-    if (err != NULL) {
-        goto out;
-    }
-
-    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
-out:
     if (err != NULL) {
     ...
     }
     ...
}


@@
type XXXCPU;
identifier initfunc, cpu_model, TYPE_XXX_CPU, XXX_CPU;
@@
 XXXCPU *initfunc(const char *cpu_model)
 {
-    return XXX_CPU(cpu_generic_init(TYPE_XXX_CPU, cpu_model));
+    CPUState *cpu = cpu_generic_init(TYPE_XXX_CPU, cpu_model);
+    Error *err = NULL;
+
+    if (!cpu) {
+        return NULL;
+    }
+
+    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+    if (err != NULL) {
+        error_report_err(err);
+        object_unref(OBJECT(cpu));
+        return NULL;
+    } else {
+        return XXX_CPU(cpu);
+    }
 }

-- 
Eduardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]