Received: from eggs.gnu.org ([2001:4830:134:3::10]:40085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brtrs-0003ZM-CW for qemu-devel@nongnu.org; Wed, 05 Oct 2016 17:36:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brtrn-00022h-46 for qemu-devel@nongnu.org; Wed, 05 Oct 2016 17:36:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43292) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brtrm-00021O-Pu for qemu-devel@nongnu.org; Wed, 05 Oct 2016 17:36:43 -0400 References: <1475696333-8706-1-git-send-email-lvivier@redhat.com> <1475696333-8706-2-git-send-email-lvivier@redhat.com> From: Laurent Vivier Message-ID: <326d2fa1-e343-2bd1-ca3b-d68c09a0b77b@redhat.com> Date: Wed, 5 Oct 2016 23:36:36 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 01/19] exec: split cpu_exec_init() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: QEMU Developers , David Gibson , Paolo Bonzini , Markus Armbruster , Eduardo Habkost , Bharata B Rao , Matthew Rosato On 05/10/2016 22:13, Peter Maydell wrote: > On 5 October 2016 at 12:38, Laurent Vivier wrote: >> Extract the realize part to cpu_exec_realize(), update all >> calls to cpu_exec_init() to add cpu_exec_realize() to >> have no functionnal change. >> >> Put in cpu_exec_init() what initializes the CPU, >> in cpu_exec_realize() what adds it to the environment. >> >> CC: Paolo Bonzini >> Signed-off-by: Laurent Vivier >> --- >> exec.c | 8 +++++--- >> include/exec/exec-all.h | 1 + >> target-alpha/cpu.c | 1 + >> target-arm/cpu.c | 1 + >> target-cris/cpu.c | 1 + >> target-i386/cpu.c | 1 + >> target-lm32/cpu.c | 1 + >> target-m68k/cpu.c | 1 + >> target-microblaze/cpu.c | 1 + >> target-mips/cpu.c | 1 + >> target-moxie/cpu.c | 1 + >> target-openrisc/cpu.c | 1 + >> target-ppc/translate_init.c | 5 +++++ >> target-s390x/cpu.c | 4 ++++ >> target-sh4/cpu.c | 1 + >> target-sparc/cpu.c | 1 + >> target-tilegx/cpu.c | 1 + >> target-tricore/cpu.c | 1 + >> target-unicore32/cpu.c | 1 + >> target-xtensa/cpu.c | 1 + >> 20 files changed, 31 insertions(+), 3 deletions(-) >> >> diff --git a/exec.c b/exec.c >> index c8389f9..95b0aee 100644 >> --- a/exec.c >> +++ b/exec.c >> @@ -614,9 +614,6 @@ void cpu_exec_exit(CPUState *cpu) >> >> void cpu_exec_init(CPUState *cpu, Error **errp) >> { >> - CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); >> - Error *local_err ATTRIBUTE_UNUSED = NULL; >> - >> cpu->as = NULL; >> cpu->num_ases = 0; >> >> @@ -637,6 +634,11 @@ void cpu_exec_init(CPUState *cpu, Error **errp) >> cpu->memory = system_memory; >> object_ref(OBJECT(cpu->memory)); >> #endif >> +} >> + >> +void cpu_exec_realize(CPUState *cpu, Error **errp) >> +{ >> + CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); >> >> cpu_list_add(cpu); > > I think cpu_list_add() needs to be in init, because > this is where we set cpu->cpu_index, and (after patch 5) > target-arm assumes that cpu_index has been set by > init but before realize. So I guess we should do it > in init and then roll back in the destructor? I think in some case cpu_list_add() can fail (no more index available), it's why it has to be in realize. In the case of hotplug we must not kill the machine. See "5a790cc cpu: Add Error argument to cpu_exec_init()" Laurent