From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kt14k-0002YX-Sq for qemu-devel@nongnu.org; Thu, 23 Oct 2008 10:22:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kt14i-0002Ww-7u for qemu-devel@nongnu.org; Thu, 23 Oct 2008 10:22:10 -0400 Received: from [199.232.76.173] (port=48484 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kt14i-0002We-1W for qemu-devel@nongnu.org; Thu, 23 Oct 2008 10:22:08 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:48052) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kt14W-00027V-58 for qemu-devel@nongnu.org; Thu, 23 Oct 2008 10:22:07 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e8.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id m9NEIX3m032743 for ; Thu, 23 Oct 2008 10:18:33 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id m9NELmgI123922 for ; Thu, 23 Oct 2008 10:21:48 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m9NELmxK030109 for ; Thu, 23 Oct 2008 10:21:48 -0400 Message-ID: <49008879.6080502@us.ibm.com> Date: Thu, 23 Oct 2008 09:21:45 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1224771556-11146-1-git-send-email-glommer@redhat.com> <1224771556-11146-23-git-send-email-glommer@redhat.com> In-Reply-To: <1224771556-11146-23-git-send-email-glommer@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 22/32] add next_cpu_index Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Glauber Costa Cc: jan.kiszka@siemens.com, jes@sgi.com, qemu-devel@nongnu.org, avi@qumranet.com, Glauber Costa , dmitry.baryshkov@siemens.com Glauber Costa wrote: > From: Glauber Costa > > separate the logic for calculating the next cpu index > from cpu creation. It will allow others to query what's > the next cpu index to be created before cpu creation. > What is this useful for? Regards, Anthony Liguori > Signed-off-by: Glauber Costa > --- > exec.c | 22 ++++++++++++++-------- > 1 files changed, 14 insertions(+), 8 deletions(-) > > diff --git a/exec.c b/exec.c > index 80b8a78..7fe7eeb 100644 > --- a/exec.c > +++ b/exec.c > @@ -526,25 +526,31 @@ static int cpu_common_load(QEMUFile *f, void *opaque, int version_id) > } > #endif > > -void cpu_exec_init(CPUState *env) > +int next_cpu_index(void) > { > CPUState **penv; > - int cpu_index; > + int cpu_index = 0; > > - env->next_cpu = NULL; > penv = &first_cpu; > - cpu_index = 0; > + > while (*penv != NULL) { > penv = (CPUState **)&(*penv)->next_cpu; > cpu_index++; > } > - env->cpu_index = cpu_index; > + return cpu_index; > +} > + > +void cpu_exec_init(CPUState *env) > +{ > + env->next_cpu = NULL; > + env->cpu_index = next_cpu_index(); > env->nb_watchpoints = 0; > - *penv = env; > + if (env->cpu_index == 0) > + first_cpu = env; > #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) > - register_savevm("cpu_common", cpu_index, CPU_COMMON_SAVE_VERSION, > + register_savevm("cpu_common", env->cpu_index, CPU_COMMON_SAVE_VERSION, > cpu_common_save, cpu_common_load, env); > - register_savevm("cpu", cpu_index, CPU_SAVE_VERSION, > + register_savevm("cpu", env->cpu_index, CPU_SAVE_VERSION, > cpu_save, cpu_load, env); > #endif > } >