From nobody Tue Nov 4 00:53:15 2025 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 1505163327294866.7441992812854; Mon, 11 Sep 2017 13:55:27 -0700 (PDT) Received: from localhost ([::1]:60522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drVjq-0000PL-GY for importer@patchew.org; Mon, 11 Sep 2017 16:55:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drVgr-0006aU-1N for qemu-devel@nongnu.org; Mon, 11 Sep 2017 16:52:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drVgj-0005qV-Vu for qemu-devel@nongnu.org; Mon, 11 Sep 2017 16:52:21 -0400 Received: from 18.mo1.mail-out.ovh.net ([46.105.35.72]:38040) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1drVgj-0005nh-P8 for qemu-devel@nongnu.org; Mon, 11 Sep 2017 16:52:13 -0400 Received: from player169.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id E9F2292E6F for ; Mon, 11 Sep 2017 22:52:10 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player169.ha.ovh.net (Postfix) with ESMTPA id 4F992580082; Mon, 11 Sep 2017 22:52:06 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Mon, 11 Sep 2017 22:52:06 +0200 Message-ID: <150516312603.27897.5390701685108186266.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: 17832565674820213075 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrgedtgdduiedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.35.72 Subject: [Qemu-devel] [PATCH] spapr_cpu_core: fail gracefully with non-pseries machine types 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, Sam Bobroff , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Since commit 7cca3e466eb0 ("ppc: spapr: Move VCPU ID calculation into sPAPR"), QEMU aborts when started with a *-spapr-cpu-core device and a non-pseries machine. Let's rely on the already existing call to object_dynamic_cast() instead of using the SPAPR_MACHINE() macro. Signed-off-by: Greg Kurz --- hw/ppc/spapr_cpu_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index d04d1e0d8164..dc9df0d393d1 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -201,7 +201,7 @@ error: =20 static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) { - sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); + sPAPRMachineState *spapr; sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(OBJECT(dev)); sPAPRCPUCoreClass *scc =3D SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev)); CPUCore *cc =3D CPU_CORE(OBJECT(dev)); @@ -211,7 +211,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Er= ror **errp) void *obj; int i, j; =20 - if (!object_dynamic_cast(qdev_get_machine(), TYPE_SPAPR_MACHINE)) { + spapr =3D (sPAPRMachineState *) qdev_get_machine(); + if (!object_dynamic_cast((Object *) spapr, TYPE_SPAPR_MACHINE)) { error_setg(errp, "spapr-cpu-core needs a pseries machine"); return; }