From patchwork Wed Jun 4 17:52:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 356057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5C7B6140094 for ; Thu, 5 Jun 2014 03:57:05 +1000 (EST) Received: from localhost ([::1]:35871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsFQt-0003kH-CE for incoming@patchwork.ozlabs.org; Wed, 04 Jun 2014 13:57:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38363) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsFQF-0002Z4-Jt for qemu-devel@nongnu.org; Wed, 04 Jun 2014 13:56:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsFQ8-0001Im-JG for qemu-devel@nongnu.org; Wed, 04 Jun 2014 13:56:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57147) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsFQ8-0001IK-Ai for qemu-devel@nongnu.org; Wed, 04 Jun 2014 13:56:16 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s54HuEk6027735 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Jun 2014 13:56:14 -0400 Received: from amt.cnet (vpn1-6-9.gru2.redhat.com [10.97.6.9]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s54HuDKs028654; Wed, 4 Jun 2014 13:56:13 -0400 Received: from amt.cnet (localhost [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id D8B001003F5; Wed, 4 Jun 2014 14:55:53 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.7/8.14.7/Submit) id s54HtrRX031276; Wed, 4 Jun 2014 14:55:53 -0300 Message-Id: <20140604175446.569449721@amt.cnet> User-Agent: quilt/0.60-1 Date: Wed, 04 Jun 2014 14:52:03 -0300 From: mtosatti@redhat.com To: qemu-devel@nongnu.org References: <20140604175200.667995104@amt.cnet> Content-Disposition: inline; filename=rtc-add-link X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: gleb@kernel.org, mprivozn@redhat.com, Marcelo Tosatti , armbru@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [patch 3/3] mc146818rtc: add "rtc" link to "/machine" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add a link to rtc under /machine providing a stable location for management apps to query "date" field. {"execute":"qom-get","arguments":{"path":"/machine/rtc","property":"date"} } Suggested by Paolo Bonzini. Signed-off-by: Marcelo Tosatti --- hw/timer/mc146818rtc.c | 9 +++++++++ 1 file changed, 9 insertions(+) Index: qemu/hw/timer/mc146818rtc.c =================================================================== --- qemu.orig/hw/timer/mc146818rtc.c 2014-06-02 23:14:11.707436729 -0300 +++ qemu/hw/timer/mc146818rtc.c 2014-06-02 23:14:15.453424684 -0300 @@ -911,6 +911,9 @@ object_property_add(OBJECT(s), "date", "struct tm", rtc_get_date, NULL, NULL, s, NULL); + + object_property_add_alias(qdev_get_machine(), "rtc", OBJECT(s), + &error_abort); } ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq) @@ -954,11 +957,17 @@ dc->cannot_instantiate_with_device_add_yet = true; } +static void rtc_finalize(Object *obj) +{ + object_property_del(qdev_get_machine(), "rtc", NULL); +} + static const TypeInfo mc146818rtc_info = { .name = TYPE_MC146818_RTC, .parent = TYPE_ISA_DEVICE, .instance_size = sizeof(RTCState), .class_init = rtc_class_initfn, + .instance_finalize = rtc_finalize, }; static void mc146818rtc_register_types(void)