From nobody Wed Feb 11 01:08:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529013371583429.6334898626619; Thu, 14 Jun 2018 14:56:11 -0700 (PDT) Received: from localhost ([::1]:43195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTaDy-0002pB-VC for importer@patchew.org; Thu, 14 Jun 2018 17:56:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTa9P-00080Z-J4 for qemu-devel@nongnu.org; Thu, 14 Jun 2018 17:51:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTa9K-00032q-Sf for qemu-devel@nongnu.org; Thu, 14 Jun 2018 17:51:27 -0400 Received: from 5.mo179.mail-out.ovh.net ([46.105.43.140]:46080) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTa9K-00031k-K4 for qemu-devel@nongnu.org; Thu, 14 Jun 2018 17:51:22 -0400 Received: from player738.ha.ovh.net (unknown [10.109.105.58]) by mo179.mail-out.ovh.net (Postfix) with ESMTP id E00F2CDA36 for ; Thu, 14 Jun 2018 23:51:20 +0200 (CEST) Received: from bahia.lan (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player738.ha.ovh.net (Postfix) with ESMTPA id 1F062ED5; Thu, 14 Jun 2018 23:51:17 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Thu, 14 Jun 2018 23:51:11 +0200 Message-ID: <152901307192.252222.7502403316148525219.stgit@bahia.lan> In-Reply-To: <152901299450.252222.14219708016930421485.stgit@bahia.lan> References: <152901299450.252222.14219708016930421485.stgit@bahia.lan> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 16381843648404887947 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedthedrleeggddtgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.43.140 Subject: [Qemu-devel] [PATCH 5/5] spapr_cpu_core: simplify spapr_cpu_core_realize() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 There's no real reason to create all CPUs in a first pass and to realize them in a second pass. Merging these two loops makes the code simpler. Signed-off-by: Greg Kurz --- hw/ppc/spapr_cpu_core.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 0ebaf804a9bc..f52af20e0096 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -172,7 +172,8 @@ error: error_propagate(errp, local_err); } =20 -static PowerPCCPU *spapr_create_vcpu(sPAPRCPUCore *sc, int i, Error **errp) +static PowerPCCPU *spapr_create_vcpu(sPAPRCPUCore *sc, int i, + sPAPRMachineState *spapr, Error **err= p) { sPAPRCPUCoreClass *scc =3D SPAPR_CPU_CORE_GET_CLASS(sc); CPUCore *cc =3D CPU_CORE(sc); @@ -201,9 +202,16 @@ static PowerPCCPU *spapr_create_vcpu(sPAPRCPUCore *sc,= int i, Error **errp) goto err; } =20 + spapr_realize_vcpu(cpu, spapr, &local_err); + if (local_err) { + goto err_unparent; + } + object_unref(obj); return cpu; =20 +err_unparent: + object_unparent(obj); err: object_unref(obj); error_propagate(errp, local_err); @@ -212,6 +220,7 @@ err: =20 static void spapr_delete_vcpu(PowerPCCPU *cpu) { + spapr_unrealize_vcpu(cpu); object_unparent(OBJECT(cpu)); } =20 @@ -226,7 +235,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Er= ror **errp) sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(OBJECT(dev)); CPUCore *cc =3D CPU_CORE(OBJECT(dev)); Error *local_err =3D NULL; - int i, j; + int i; =20 if (!spapr) { error_setg(errp, TYPE_SPAPR_CPU_CORE " needs a pseries machine"); @@ -235,24 +244,14 @@ static void spapr_cpu_core_realize(DeviceState *dev, = Error **errp) =20 sc->threads =3D g_new(PowerPCCPU *, cc->nr_threads); for (i =3D 0; i < cc->nr_threads; i++) { - sc->threads[i] =3D spapr_create_vcpu(sc, i, &local_err); + sc->threads[i] =3D spapr_create_vcpu(sc, i, spapr, &local_err); if (local_err) { goto err; } } =20 - for (j =3D 0; j < cc->nr_threads; j++) { - spapr_realize_vcpu(sc->threads[j], spapr, &local_err); - if (local_err) { - goto err_unrealize; - } - } return; =20 -err_unrealize: - while (--j >=3D 0) { - spapr_unrealize_vcpu(sc->threads[i]); - } err: while (--i >=3D 0) { spapr_delete_vcpu(sc->threads[i]);