From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTXru-0005U9-3t for qemu-devel@nongnu.org; Thu, 05 Mar 2015 10:39:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YTXrp-0000FI-A8 for qemu-devel@nongnu.org; Thu, 05 Mar 2015 10:39:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38976) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTXrp-0000F9-2K for qemu-devel@nongnu.org; Thu, 05 Mar 2015 10:39:17 -0500 From: Eduardo Habkost Date: Thu, 5 Mar 2015 12:38:49 -0300 Message-Id: <1425569930-6660-6-git-send-email-ehabkost@redhat.com> In-Reply-To: <1425569930-6660-1-git-send-email-ehabkost@redhat.com> References: <1425569930-6660-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH 5/6] target-i386: Move TCG initialization to realize time List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: zhugh.fnst@cn.fujitsu.com, tangchen@cn.fujitsu.com, chen.fan.fnst@cn.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com, Paolo Bonzini , Gu Zheng , Igor Mammedov , anshul.makkar@profitbricks.com, =?UTF-8?q?Andreas=20F=C3=A4rber?= To ask the CPU classes for CPU model information and allow QOM properties to be queried by qmp_device_list_properties(), we need to be able to safely instantiate a X86CPU object without any side-effects. Move TCG initialization to realize time so it won't be called when just doing object_new() on a X86CPU subclass. Signed-off-by: Eduardo Habkost --- target-i386/cpu.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index b4e70d3..400b1e0 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2756,6 +2756,12 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) CPUX86State *env = &cpu->env; Error *local_err = NULL; static bool ht_warned; + static bool tcg_initialized; + + if (tcg_enabled() && !tcg_initialized) { + tcg_initialized = 1; + tcg_x86_init(); + } if (cpu->apic_id < 0) { error_setg(errp, "apic-id property was not initialized properly"); @@ -2832,7 +2838,6 @@ static void x86_cpu_initfn(Object *obj) X86CPU *cpu = X86_CPU(obj); X86CPUClass *xcc = X86_CPU_GET_CLASS(obj); CPUX86State *env = &cpu->env; - static int inited; cs->env_ptr = env; cpu_exec_init(env); @@ -2879,12 +2884,6 @@ static void x86_cpu_initfn(Object *obj) #endif x86_cpu_load_def(cpu, xcc->cpu_def, &error_abort); - - /* init various static tables used in TCG mode */ - if (tcg_enabled() && !inited) { - inited = 1; - tcg_x86_init(); - } } static int64_t x86_cpu_get_arch_id(CPUState *cs) -- 2.1.0