From patchwork Mon Jun 2 17:51:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 355007 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 0ED9A1400A3 for ; Tue, 3 Jun 2014 03:56:51 +1000 (EST) Received: from localhost ([::1]:48530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrWTZ-0003uE-1b for incoming@patchwork.ozlabs.org; Mon, 02 Jun 2014 13:56:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrWSy-0002oJ-Fh for qemu-devel@nongnu.org; Mon, 02 Jun 2014 13:56:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrWSm-0003Ar-Oi for qemu-devel@nongnu.org; Mon, 02 Jun 2014 13:56:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15056) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrWSm-0003Af-Ff for qemu-devel@nongnu.org; Mon, 02 Jun 2014 13:56:00 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s52Htwvu002127 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Jun 2014 13:55:58 -0400 Received: from amt.cnet (vpn1-5-214.gru2.redhat.com [10.97.5.214]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s52Htv0H030603; Mon, 2 Jun 2014 13:55:57 -0400 Received: from amt.cnet (localhost [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 8C76B100401; Mon, 2 Jun 2014 14:55:15 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.7/8.14.7/Submit) id s52HtFeg005310; Mon, 2 Jun 2014 14:55:15 -0300 Message-Id: <20140602175345.392851716@amt.cnet> User-Agent: quilt/0.60-1 Date: Mon, 02 Jun 2014 14:51:07 -0300 From: mtosatti@redhat.com To: qemu-devel@nongnu.org References: <20140530201145.194061806@amt.cnet> <20140602175104.579823673@amt.cnet> Content-Disposition: inline; filename=rtc-add-link X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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 Index: qemu/hw/timer/mc146818rtc.c =================================================================== --- qemu.orig/hw/timer/mc146818rtc.c +++ qemu/hw/timer/mc146818rtc.c @@ -911,6 +911,9 @@ static void rtc_realizefn(DeviceState *d 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 @@ static void rtc_class_initfn(ObjectClass 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)