From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPIRV-0001sF-L5 for qemu-devel@nongnu.org; Mon, 08 Apr 2013 16:13:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPIRQ-00017S-ME for qemu-devel@nongnu.org; Mon, 08 Apr 2013 16:13:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPIRQ-00017G-Br for qemu-devel@nongnu.org; Mon, 08 Apr 2013 16:13:24 -0400 Date: Mon, 8 Apr 2013 17:13:11 -0300 From: Eduardo Habkost Message-ID: <20130408201311.GI2719@otherpad.lan.raisama.net> References: <1365172636-28628-1-git-send-email-imammedo@redhat.com> <1365172636-28628-7-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1365172636-28628-7-git-send-email-imammedo@redhat.com> Subject: Re: [Qemu-devel] [PATCH 06/22] cpu: introduce CPUClass.resume() method List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: aliguori@us.ibm.com, claudio.fontana@huawei.com, qemu-devel@nongnu.org, aderumier@odiso.com, lcapitulino@redhat.com, jfrei@linux.vnet.ibm.com, yang.z.zhang@intel.com, pbonzini@redhat.com, afaerber@suse.de, lig.fnst@cn.fujitsu.com, rth@twiddle.net On Fri, Apr 05, 2013 at 04:36:58PM +0200, Igor Mammedov wrote: > ... and call it if defined from CPUClass.realize() if CPU was hotplugged > > by default leave .resume() unset (i.e. NULL) and override it for softmmu > in qemu_init_vcpu() if it's still unset. > > Signed-off-by: Igor Mammedov [...] > diff --git a/cpus.c b/cpus.c > index 9b9a32f..6b793c5 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -973,6 +973,13 @@ void pause_all_vcpus(void) [...] > @@ -1042,7 +1047,11 @@ void qemu_init_vcpu(void *_env) > { > CPUArchState *env = _env; > CPUState *cpu = ENV_GET_CPU(env); > + CPUClass *klass = CPU_GET_CLASS(cpu); > > + if (klass->resume == NULL) { > + klass->resume = resume_vcpu; > + } So you are initializing a field of CPUClass struct inside a CPU object initialization function. And that's a function that is not even converted to QOM yet, and buried inside a non-trivial function call tree (hence easy to be called at the wrong time if one day we reorder the initialization steps). Can't we do this on class_init(), where it belongs? If we need different implementations for softmmu/user, we can add a stub for *-user. I think even an explicit #ifdef inside resume_vcpu() would be preferable to this. > cpu->nr_cores = smp_cores; > cpu->nr_threads = smp_threads; > cpu->stopped = true; [...] -- Eduardo