v2: - fix changelog to mention "machine" not "machines
    - remove TARGET_I386 ifdef

-------------
    

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 <mtosa...@redhat.com>

Index: qemu/hw/timer/mc146818rtc.c
===================================================================
--- qemu.orig/hw/timer/mc146818rtc.c
+++ qemu/hw/timer/mc146818rtc.c
@@ -63,6 +63,7 @@
 typedef struct RTCState {
     ISADevice parent_obj;
 
+    Object *rtc_object;
     MemoryRegion io;
     uint8_t cmos_data[128];
     uint8_t cmos_index;
@@ -856,6 +857,8 @@ static void rtc_realizefn(DeviceState *d
     RTCState *s = MC146818_RTC(dev);
     int base = 0x70;
 
+    s->rtc_object = OBJECT(s);
+
     s->cmos_data[RTC_REG_A] = 0x26;
     s->cmos_data[RTC_REG_B] = 0x02;
     s->cmos_data[RTC_REG_C] = 0x00;
@@ -908,6 +911,10 @@ static void rtc_realizefn(DeviceState *d
 
     object_property_add(OBJECT(s), "date", "struct tm",
                         rtc_get_date, NULL, NULL, s, NULL);
+
+    object_ref(s->rtc_object);
+    object_property_add_link(qdev_get_machine(), "rtc", TYPE_MC146818_RTC,
+                            (Object **)&s->rtc_object, NULL, 0, &error_abort);
 }
 
 ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)

Reply via email to