From nobody Wed Nov 5 14:27:33 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; 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; 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 1534871882643711.6724371971519; Tue, 21 Aug 2018 10:18:02 -0700 (PDT) Received: from localhost ([::1]:55012 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsAI1-00062E-Sz for importer@patchew.org; Tue, 21 Aug 2018 13:17:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsA49-0001SV-85 for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:03:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsA3z-0005yz-JS for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:03:31 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:46454) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fsA3s-0005ie-3h for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:03:21 -0400 Received: by mail-wr1-x433.google.com with SMTP id a108-v6so13814869wrc.13 for ; Tue, 21 Aug 2018 10:03:18 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v6-v6sm2608955wmc.43.2018.08.21.10.03.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 10:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=+EiNerbP1pk7gA6CFNncAQS/IxgM5wfOMJfiv+7i/bU=; b=Ju5R3Abj55zL3xZproY3x065jTC1oxGvtKFE1HG1otor/bJYqzKblHwJE/TNNwHkDk hUkxrxqtDnMTSNWwWnpAM3pySbpeIazDoF9zbUoId8VdKUtu9g6WJWzB4Bue9xyXIqgh JOW9wtGpTe2YHcC7tz34hhfJYqUPpjP3OzLmLVfjam5BGks3wDC0Xt3oBkiPjZ83obkC BMXTMso1QLFTOcPajNB1diFu5AJxDWyNIT9C46/PKJeBXxQ/qjBxUktBqWRP72ElGdY2 oYkSwJ3xgurfb9xF4K2wCzNyS2Y7SAByLR+rhXNuSiMtyuSFJx3Tk72SC/XliIYyOyh0 m0eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=+EiNerbP1pk7gA6CFNncAQS/IxgM5wfOMJfiv+7i/bU=; b=PwjV9G+XtlbNdxfywQ1tLmZqrQpiOP37vfSjXadMavyTp7nRY2tWuqPVst+pL7YKMU K3Wb3P2BVhEihGDAmN6CO3g+b6VHkFXSb/w0l8o4gU+iwWBPUfgo8+okoxW2UlWfSURl vkZYDHNDwxEBAux7zseA/l8Zbw1WfQBYlKERt5vtXID5VSt6QatS3JynAIVGo36FRbSd Ay4NYNoNdTiZohrIReQGZxCA1fAA0WUSYYqnleun4iigp/lmpBqOM/HU+K1VoiMwHyIY MmUdfV0ioVQWnzS3MfD/9Dyy1tp7hG+4K0srCa6VJ6ZNgjSDKcmzT0HAEo/9ErrTcxR2 DREQ== X-Gm-Message-State: AOUpUlH/D+Ah9mMe8arplz0TscKA5ngnHG8Uq2FwTOiDjSDSxMfb7xJn TlxNmwH/31gRDQfl9s18IsadX+PC X-Google-Smtp-Source: AA+uWPyYcTEGQ/ndTl2w/axZwJHzAnqwZqYap0oHMLkf5pxCJmWACy2r6odgLzkT6u/TYVJ4HUTJdQ== X-Received: by 2002:a5d:6550:: with SMTP id z16-v6mr31398761wrv.194.1534870997023; Tue, 21 Aug 2018 10:03:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2018 19:01:45 +0200 Message-Id: <1534870966-9287-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> References: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::433 Subject: [Qemu-devel] [PULL 13/74] 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: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 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 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 have been done in an unrealize function, not in a finalize function, to avoid that this causes problems during introspection. But since adding aliases to the global machine state should not be done from a device's realize function anyway, let's rather fix this issue by moving the creation of the alias to the code that creates the device (and thus is run from the machine init functions instead), i.e. the mc146818_rtc_init() function for most machines. The prep machines are special, since the mc146818rtc device is created here in the realize function of the i82378 device. Since we certainly don't want to add the alias there, we add it to some code that is called from the ibm_40p_init() machine init function instead. Since the alias is now only created during the machine init, we can remove the object_property_del() completely. Fixes: 654a36d857ff949e0d1989904b76f53fded9dc83 Reviewed-by: Markus Armbruster Signed-off-by: Thomas Huth Message-Id: <1534419358-10932-5-git-send-email-thuth@redhat.com> Reviewed-by: Juan Quintela Signed-off-by: Paolo Bonzini --- hw/ppc/prep.c | 3 +++ hw/timer/mc146818rtc.c | 12 +++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index 3401570..91a8f42 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -696,6 +696,9 @@ static int prep_set_cmos_checksum(DeviceState *dev, voi= d *opaque) rtc_set_memory(rtc, 0x3e, checksum & 0xff); rtc_set_memory(rtc, 0x2f, checksum >> 8); rtc_set_memory(rtc, 0x3f, checksum >> 8); + + object_property_add_alias(qdev_get_machine(), "rtc-time", OBJECT(r= tc), + "date", NULL); } return 0; } diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c index 3a14075..a504f03 100644 --- a/hw/timer/mc146818rtc.c +++ b/hw/timer/mc146818rtc.c @@ -995,9 +995,6 @@ static void rtc_realizefn(DeviceState *dev, Error **err= p) =20 object_property_add_tm(OBJECT(s), "date", rtc_get_date, NULL); =20 - object_property_add_alias(qdev_get_machine(), "rtc-time", - OBJECT(s), "date", NULL); - qdev_init_gpio_out(dev, &s->irq, 1); } =20 @@ -1019,6 +1016,9 @@ ISADevice *mc146818_rtc_init(ISABus *bus, int base_ye= ar, qemu_irq intercept_irq) } QLIST_INSERT_HEAD(&rtc_devices, s, link); =20 + object_property_add_alias(qdev_get_machine(), "rtc-time", OBJECT(s), + "date", NULL); + return isadev; } =20 @@ -1052,17 +1052,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