From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKq43-0006NF-St for qemu-devel@nongnu.org; Wed, 06 Jul 2016 12:52:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKq3y-0008Fa-PE for qemu-devel@nongnu.org; Wed, 06 Jul 2016 12:52:42 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:62772 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKq3y-0008FT-Ji for qemu-devel@nongnu.org; Wed, 06 Jul 2016 12:52:38 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u66GiO8W089067 for ; Wed, 6 Jul 2016 12:52:38 -0400 Received: from e28smtp03.in.ibm.com (e28smtp03.in.ibm.com [125.16.236.3]) by mx0b-001b2d01.pphosted.com with ESMTP id 240k6x3mkw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 06 Jul 2016 12:52:37 -0400 Received: from localhost by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 Jul 2016 22:22:34 +0530 Date: Wed, 6 Jul 2016 22:22:21 +0530 From: Bharata B Rao Reply-To: bharata@linux.vnet.ibm.com References: <1467795561-1007-1-git-send-email-bharata@linux.vnet.ibm.com> <1467795561-1007-2-git-send-email-bharata@linux.vnet.ibm.com> <20160706125749.5a38adab@172-15-179-184.lightspeed.austtx.sbcglobal.net> <20160706141613.GE25522@in.ibm.com> <20160706164417.414af317@172-15-179-184.lightspeed.austtx.sbcglobal.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160706164417.414af317@172-15-179-184.lightspeed.austtx.sbcglobal.net> Message-Id: <20160706165221.GI25522@in.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v1 1/5] cpu, target-ppc: Move cpu_vmstate_[un]register calls to cpu_common_[un]realize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au, groug@kaod.org, nikunj@linux.vnet.ibm.com, pbonzini@redhat.com On Wed, Jul 06, 2016 at 04:44:17PM +0200, Igor Mammedov wrote: > On Wed, 6 Jul 2016 19:46:13 +0530 > Bharata B Rao wrote: > > > On Wed, Jul 06, 2016 at 12:57:49PM +0200, Igor Mammedov wrote: > > > On Wed, 6 Jul 2016 14:29:17 +0530 > > > Bharata B Rao wrote: > > > > > > > Move vmstate_register() call to cpu_common_realize(). > > > > Introduce cpu_common_unrealize() and move vmstate_unregister() to > > > > it. > > > > > > > > Change those archs that implement their own CPU unrealize routine > > > > to mandatorily call CPUClass::unrealize(). > > > > > > > > Signed-off-by: Bharata B Rao > > > > --- > > > > exec.c | 53 > > > > ++++++++++++++++++++++++++++----------------- > > > > include/qom/cpu.h | 2 ++ qom/cpu.c > > > > | 7 ++++++ target-ppc/cpu-qom.h | 2 ++ > > > > target-ppc/translate_init.c | 3 +++ > > > > 5 files changed, 47 insertions(+), 20 deletions(-) > > > > > > > > diff --git a/exec.c b/exec.c > > > > index 0122ef7..fb73910 100644 > > > > --- a/exec.c > > > > +++ b/exec.c > > > > @@ -594,9 +594,7 @@ AddressSpace *cpu_get_address_space(CPUState > > > > *cpu, int asidx) /* Return the AddressSpace corresponding to the > > > > specified index */ return cpu->cpu_ases[asidx].as; > > > > } > > > > -#endif > > > > > > > > -#ifndef CONFIG_USER_ONLY > > > > static DECLARE_BITMAP(cpu_index_map, MAX_CPUMASK_BITS); > > > > > > > > static int cpu_get_free_index(Error **errp) > > > > @@ -617,6 +615,31 @@ static void cpu_release_index(CPUState *cpu) > > > > { > > > > bitmap_clear(cpu_index_map, cpu->cpu_index, 1); > > > > } > > > > + > > > > +void cpu_vmstate_register(CPUState *cpu) > > > > +{ > > > > + CPUClass *cc = CPU_GET_CLASS(cpu); > > > > + > > > > + if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { > > > > + vmstate_register(NULL, cpu->cpu_index, > > > > &vmstate_cpu_common, cpu); > > > > + } > > > > + if (cc->vmsd != NULL) { > > > > + vmstate_register(NULL, cpu->cpu_index, cc->vmsd, cpu); > > > > + } > > > > +} > > > > + > > > > +void cpu_vmstate_unregister(CPUState *cpu) > > > > +{ > > > > + CPUClass *cc = CPU_GET_CLASS(cpu); > > > > + > > > > + if (cc->vmsd != NULL) { > > > > + vmstate_unregister(NULL, cc->vmsd, cpu); > > > > + } > > > > + if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { > > > > + vmstate_unregister(NULL, &vmstate_cpu_common, cpu); > > > > + } > > > > +} > > > > > > Is there any reason to keep these in exec.c, > > > I'd put them in qom/cpu.c > > > > I started with it, had to move vmstate_cpu_common and its > > pre/post_load routines and one of them called tlb_flush() whose > > header qom/cpu.c didn't like. So I saved the movement for later. > ok, > > alternatively you can check for use_migration_id in exec.c without > moving vmstate_* around. Ok, just to be clear, you are suggesting that I move back to my first implementation which just consolidated vmstate_* calls and called them from within cpu_exec_init/exit() ? Regards, Bharata.