From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPVlL-0003UP-Op for qemu-devel@nongnu.org; Tue, 09 Apr 2013 06:26:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPVlK-0007WU-N8 for qemu-devel@nongnu.org; Tue, 09 Apr 2013 06:26:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPVlK-0007WO-EC for qemu-devel@nongnu.org; Tue, 09 Apr 2013 06:26:50 -0400 Date: Tue, 9 Apr 2013 12:26:35 +0200 From: Igor Mammedov Message-ID: <20130409122635.6c8df15f@nial.usersys.redhat.com> In-Reply-To: <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> <20130408201311.GI2719@otherpad.lan.raisama.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: Eduardo Habkost , pbonzini@redhat.com 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, afaerber@suse.de, lig.fnst@cn.fujitsu.com, rth@twiddle.net On Mon, 8 Apr 2013 17:13:11 -0300 Eduardo Habkost wrote: > 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). init step are not likely to change this drastically but main reason why it's here see below. > > 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. Generally I agree with you that class_init() would be more correct, but ifdefs in qom/cpu.c defeat purpose to build qom/cpu.c only once for all targets, that Andreas are working towards. It asks surely asks for resume_vcpu() stub in libqemustubs, and I'd do it there weren't objections to it. Paolo, it looks like a good candidate for libqemustubs, would it be ok to add stub there? > > > > cpu->nr_cores = smp_cores; > > cpu->nr_threads = smp_threads; > > cpu->stopped = true; > [...] >