From nobody Sun May 5 05:54:12 2024 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 1503546814932504.98465591064223; Wed, 23 Aug 2017 20:53:34 -0700 (PDT) Received: from localhost ([::1]:46594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkjD1-0006D6-Hv for importer@patchew.org; Wed, 23 Aug 2017 23:53:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkjCB-0005jx-Jm for qemu-devel@nongnu.org; Wed, 23 Aug 2017 23:52:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkjC8-0001Ny-EK for qemu-devel@nongnu.org; Wed, 23 Aug 2017 23:52:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48570) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkjC8-0001Mt-7b; Wed, 23 Aug 2017 23:52:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 079EA882FF; Thu, 24 Aug 2017 03:52:35 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-37.ams2.redhat.com [10.36.116.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88FAF69A7E; Thu, 24 Aug 2017 03:52:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 079EA882FF Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=thuth@redhat.com From: Thomas Huth To: qemu-devel@nongnu.org, David Gibson Date: Thu, 24 Aug 2017 05:52:32 +0200 Message-Id: <1503546752-24569-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 24 Aug 2017 03:52:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 for-2.11] 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-ppc@nongnu.org, Eduardo Habkost , Bharata B Rao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- v2: - Add the check to spapr_cpu_core_realize() instead of adding it to spapr_cpu_core_realize_child() - Use device/machine whitelist for the device-crash-test instead of adding a log entry there 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 ea278ce..dd92326 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 81d65b9..043b24a 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 1.8.3.1