Received: from eggs.gnu.org ([2001:4830:134:3::10]:33585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMyIC-0007r6-AZ for qemu-devel@nongnu.org; Sat, 23 Jan 2016 08:31:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMyI9-0000Zm-2M for qemu-devel@nongnu.org; Sat, 23 Jan 2016 08:31:52 -0500 Date: Sat, 23 Jan 2016 11:31:44 -0200 From: Eduardo Habkost Message-ID: <20160123133144.GH3869@thinpad.lan.raisama.net> References: <1452236119-24452-1-git-send-email-bharata@linux.vnet.ibm.com> <1452236119-24452-5-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1452236119-24452-5-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v6 04/11] cpu: Don't realize CPU from cpu_generic_init() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, agraf@suse.de, qemu-devel@nongnu.org, pbonzini@redhat.com, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com, afaerber@suse.de, david@gibson.dropbear.id.au 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 Reviewed-by: Eduardo Habkost 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