From nobody Sat May 4 20:43:15 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1532010274093110.15508765587776; Thu, 19 Jul 2018 07:24:34 -0700 (PDT) Received: from localhost ([::1]:43560 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fg9r6-0006tT-Oq for importer@patchew.org; Thu, 19 Jul 2018 10:24:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fg9q7-0006U9-65 for qemu-devel@nongnu.org; Thu, 19 Jul 2018 10:23:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fg9q3-0005nC-6Q for qemu-devel@nongnu.org; Thu, 19 Jul 2018 10:23:31 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55838 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 1fg9q3-0005mo-1B; Thu, 19 Jul 2018 10:23:27 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 385A5402243B; Thu, 19 Jul 2018 14:23:26 +0000 (UTC) Received: from thh440s.str.redhat.com (dhcp-200-180.str.redhat.com [10.33.200.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0058111AF0C; Thu, 19 Jul 2018 14:23:23 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Paolo Bonzini Date: Thu, 19 Jul 2018 16:23:23 +0200 Message-Id: <1532010203-21331-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 19 Jul 2018 14:23:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 19 Jul 2018 14:23:26 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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/timer/mc146818rtc: Fix introspection problem 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, "Michael S. Tsirkin" 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" There is currently a funny problem with the "mc146818rtc" device: 1) Start QEMU like this: qemu-system-ppc64 -M pseries -S 2) At the HMP monitor, enter "info qom-tree". Note that there is an entry for "/rtc (spapr-rtc)". 3) Introspect the mc146818rtc device like this: device_add mc146818rtc,help 4) Run "info qom-tree" again. The "/rtc" entry is gone now! The rtc_finalize() function of the mc146818rtc device has two bugs: First, it tries to remove a "rtc" property, while the rtc_realizefn() added a "rtc-time" property instead. And second, it should be done in an unrealize function, not in a finalize function, to avoid that this causes problems during introspection. Fixes: 654a36d857ff949e0d1989904b76f53fded9dc83 Signed-off-by: Thomas Huth --- hw/timer/mc146818rtc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c index 6f1f723..c0c6a72 100644 --- a/hw/timer/mc146818rtc.c +++ b/hw/timer/mc146818rtc.c @@ -1001,6 +1001,11 @@ static void rtc_realizefn(DeviceState *dev, Error **= errp) qdev_init_gpio_out(dev, &s->irq, 1); } =20 +static void rtc_unrealize(DeviceState *dev, Error **errp) +{ + object_property_del(qdev_get_machine(), "rtc-time", errp); +} + ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, qemu_irq intercep= t_irq) { DeviceState *dev; @@ -1045,6 +1050,7 @@ static void rtc_class_initfn(ObjectClass *klass, void= *data) DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->realize =3D rtc_realizefn; + dc->unrealize =3D rtc_unrealize; dc->reset =3D rtc_resetdev; dc->vmsd =3D &vmstate_rtc; dc->props =3D mc146818rtc_properties; @@ -1052,17 +1058,11 @@ static void rtc_class_initfn(ObjectClass *klass, vo= id *data) dc->user_creatable =3D false; } =20 -static void rtc_finalize(Object *obj) -{ - object_property_del(qdev_get_machine(), "rtc", NULL); -} - static const TypeInfo mc146818rtc_info =3D { .name =3D TYPE_MC146818_RTC, .parent =3D TYPE_ISA_DEVICE, .instance_size =3D sizeof(RTCState), .class_init =3D rtc_class_initfn, - .instance_finalize =3D rtc_finalize, }; =20 static void mc146818rtc_register_types(void) --=20 1.8.3.1