From nobody Tue Feb 10 04:17:19 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; dkim=fail; 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 1504867800631559.979891669045; Fri, 8 Sep 2017 03:50:00 -0700 (PDT) Received: from localhost ([::1]:44508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqGrH-0006HQ-C8 for importer@patchew.org; Fri, 08 Sep 2017 06:49:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58775) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqGe9-0002Cj-Eo for qemu-devel@nongnu.org; Fri, 08 Sep 2017 06:36:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqGe2-0003Hh-W2 for qemu-devel@nongnu.org; Fri, 08 Sep 2017 06:36:25 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:52373) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dqGe2-0003FJ-Li; Fri, 08 Sep 2017 06:36:18 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3xpYdP02wlz9t5Q; Fri, 8 Sep 2017 20:36:07 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1504866969; bh=SuJe/RiY3eIS3InJzfDxBncB7dnqxfKnAMpwy7DOwU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P+JuYLu8LehkEKywtBC5N+jvuG01rDFLfG3TFtSYVyp7wILqf+//jrLwpsMwUp7DX Z7G3vM4CfL0eu0C/QTLqk4E9W8YrIwiVSisDy2VyHlabDzy4E+1l3FJEFYqROk2f05 BlyzRuU3AmlA43k5l2M7vbqELUKgO4U0rwsKn+Vc= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 8 Sep 2017 20:35:46 +1000 Message-Id: <20170908103558.31632-29-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170908103558.31632-1-david@gibson.dropbear.id.au> References: <20170908103558.31632-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 28/40] hw/ppc/spapr_cpu_core: Add a proper check for spapr machine 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-devel@nongnu.org, aik@ozlabs.ru, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-ppc@nongnu.org, Thomas Huth , imammedo@redhat.com, sam.bobroff@au1.ibm.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth QEMU currently crashes when the user tries to add a spapr-cpu-core on a non-pseries machine: $ qemu-system-ppc64 -S -machine ppce500,accel=3Dtcg \ -device POWER5+_v2.1-spapr-cpu-core hw/ppc/spapr_cpu_core.c:178:spapr_cpu_core_realize_child: Object 0x55cee1f55160 is not an instance of type spapr-machine Aborted (core dumped) So let's add a proper check for the correct machine time with a more friendly error message here. Reported-by: Eduardo Habkost Signed-off-by: Thomas Huth Signed-off-by: David Gibson --- hw/ppc/spapr_cpu_core.c | 5 +++++ scripts/device-crash-test | 3 +++ 2 files changed, 8 insertions(+) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index ea278ce2a7..dd9232620d 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -220,6 +220,11 @@ static void spapr_cpu_core_realize(DeviceState *dev, E= rror **errp) void *obj; int i, j; =20 + if (!object_dynamic_cast(qdev_get_machine(), TYPE_SPAPR_MACHINE)) { + error_setg(errp, "spapr-cpu-core needs a pseries machine"); + return; + } + sc->threads =3D g_malloc0(size * cc->nr_threads); for (i =3D 0; i < cc->nr_threads; i++) { char id[32]; diff --git a/scripts/device-crash-test b/scripts/device-crash-test index 81d65b9617..043b24a4aa 100755 --- a/scripts/device-crash-test +++ b/scripts/device-crash-test @@ -160,6 +160,9 @@ ERROR_WHITELIST =3D [ {'machine':'q35|pc.*', 'device':'kvm-ioapic', 'expected':True}, # Only= 1 ioapics allowed {'machine':'q35|pc.*', 'device':'ioapic', 'expected':True}, # Only= 1 ioapics allowed =20 + # "spapr-cpu-core needs a pseries machine" + {'machine':'(?!pseries).*', 'device':'.*-spapr-cpu-core', 'expected':T= rue}, + # KVM-specific devices shouldn't be tried without accel=3Dkvm: {'accel':'(?!kvm).*', 'device':'kvmclock', 'expected':True}, {'accel':'(?!kvm).*', 'device':'kvm-pci-assign', 'expected':True}, --=20 2.13.5