From nobody Mon Apr 29 01:19:21 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 1522920845498381.0363559065423; Thu, 5 Apr 2018 02:34:05 -0700 (PDT) Received: from localhost ([::1]:43368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f41HL-0008Ni-9j for importer@patchew.org; Thu, 05 Apr 2018 05:33:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f41G8-0007xO-QW for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:32:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f41G4-0003QM-T0 for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:32:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:52756 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f41G4-0003Q2-Oq for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:32:40 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C45D77067; Thu, 5 Apr 2018 09:32:36 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-84.ams2.redhat.com [10.36.116.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F0156352A; Thu, 5 Apr 2018 09:32:31 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Mark Cave-Ayland Date: Thu, 5 Apr 2018 11:32:30 +0200 Message-Id: <1522920750-11020-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 05 Apr 2018 09:32:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 05 Apr 2018 09:32:36 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] hw/sparc64/sun4u: Fix introspection by converting prom instance_init to 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: Artyom Tarasenko 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" The instance_init function of devices should always succeed to be able to introspect the device. However, the instance_init function of the "openprom" device can currently fail, for example like this: $ echo "{'execute':'qmp_capabilities'}"\ "{'execute':'device-list-properties',"\ " 'arguments':{'typename':'openprom'}}" \ | sparc64-softmmu/qemu-system-sparc64 -M sun4v,accel=3Dqtest -qmp st= dio {"QMP": {"version": {"qemu": {"micro": 91, "minor": 11, "major": 2}, "package": "build-all"}, "capabilities": []}} {"return": {}} RAMBlock "sun4u.prom" already registered, abort! Aborted (core dumped) This should not happen. Fix this problem by moving the affected code from instance_init into a realize function instead. Signed-off-by: Thomas Huth Acked-by: Artyom Tarasenko Reviewed-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/sparc64/sun4u.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 2044a52..d62f5a2 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -425,13 +425,19 @@ static void prom_init(hwaddr addr, const char *bios_n= ame) } } =20 -static void prom_init1(Object *obj) +static void prom_realize(DeviceState *ds, Error **errp) { - PROMState *s =3D OPENPROM(obj); - SysBusDevice *dev =3D SYS_BUS_DEVICE(obj); + PROMState *s =3D OPENPROM(ds); + SysBusDevice *dev =3D SYS_BUS_DEVICE(ds); + Error *local_err =3D NULL; + + memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.prom", + PROM_SIZE_MAX, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } =20 - memory_region_init_ram_nomigrate(&s->prom, obj, "sun4u.prom", PROM_SIZ= E_MAX, - &error_fatal); vmstate_register_ram_global(&s->prom); memory_region_set_readonly(&s->prom, true); sysbus_init_mmio(dev, &s->prom); @@ -446,6 +452,7 @@ static void prom_class_init(ObjectClass *klass, void *d= ata) DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->props =3D prom_properties; + dc->realize =3D prom_realize; } =20 static const TypeInfo prom_info =3D { @@ -453,7 +460,6 @@ static const TypeInfo prom_info =3D { .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(PROMState), .class_init =3D prom_class_init, - .instance_init =3D prom_init1, }; =20 =20 --=20 1.8.3.1