[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCHv3 9/9] pseries: Export RTC time via QOM
From: |
David Gibson |
Subject: |
[Qemu-devel] [PATCHv3 9/9] pseries: Export RTC time via QOM |
Date: |
Fri, 6 Feb 2015 14:55:53 +1100 |
On x86, the guest's RTC can be read with QMP, either from the RTC device's
"date" property or via the "rtc-time" property on the machine (which is an
alias to the former). This is set up in the mc146818rtc driver, and
doesn't work on other targets.
This patch adds a similar "date" property to the pseries machine's RTAS RTC
and adds a compatible alias to the machine.
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr.c | 3 +++
hw/ppc/spapr_rtc.c | 7 +++++++
2 files changed, 10 insertions(+)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 2264802..e6623e1 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -999,6 +999,9 @@ static void spapr_rtc_create(sPAPREnvironment *spapr)
qdev_init_nofail(dev);
spapr->rtc = dev;
+
+ object_property_add_alias(qdev_get_machine(), "rtc-time",
+ OBJECT(spapr->rtc), "date", NULL);
}
/* Returns whether we want to use VGA or not */
diff --git a/hw/ppc/spapr_rtc.c b/hw/ppc/spapr_rtc.c
index 5ad0823..83eb7c1 100644
--- a/hw/ppc/spapr_rtc.c
+++ b/hw/ppc/spapr_rtc.c
@@ -152,6 +152,11 @@ static void rtas_set_time_of_day(PowerPCCPU *cpu,
sPAPREnvironment *spapr,
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
}
+static void spapr_rtc_qom_date(Object *obj, struct tm *current_tm, Error
**errp)
+{
+ spapr_rtc_read(DEVICE(obj), current_tm, NULL);
+}
+
static void spapr_rtc_realize(DeviceState *dev, Error **errp)
{
sPAPRRTCState *rtc = SPAPR_RTC(dev);
@@ -165,6 +170,8 @@ static void spapr_rtc_realize(DeviceState *dev, Error
**errp)
host_s = mktimegm(&tm);
rtc_ns = qemu_clock_get_ns(rtc_clock);
rtc->ns_offset = host_s * NSEC_PER_SEC - rtc_ns;
+
+ object_property_add_tm(OBJECT(rtc), "date", spapr_rtc_qom_date, NULL);
}
static const VMStateDescription vmstate_spapr_rtc = {
--
2.1.0
- [Qemu-devel] [PATCHv3 0/9] pseries: Fix and extend PAPR RTC implementation, David Gibson, 2015/02/05
- [Qemu-devel] [PATCHv3 2/9] Add more VMSTATE_*_TEST variants for integers, David Gibson, 2015/02/05
- [Qemu-devel] [PATCHv3 6/9] pseries: Make RTAS time of day functions respect -rtc options, David Gibson, 2015/02/05
- [Qemu-devel] [PATCHv3 1/9] Generalize QOM publishing of date and time from mc146818rtc.c, David Gibson, 2015/02/05
- [Qemu-devel] [PATCHv3 5/9] pseries: Add spapr_rtc_read() helper function, David Gibson, 2015/02/05
- [Qemu-devel] [PATCHv3 8/9] pseries: Move rtc_offset into RTC device's state structure, David Gibson, 2015/02/05
- [Qemu-devel] [PATCHv3 7/9] pseries: Make the PAPR RTC a qdev device, David Gibson, 2015/02/05
- [Qemu-devel] [PATCHv3 3/9] pseries: Move sPAPR RTC code into its own file, David Gibson, 2015/02/05
- [Qemu-devel] [PATCHv3 9/9] pseries: Export RTC time via QOM,
David Gibson <=
- [Qemu-devel] [PATCHv3 4/9] pseries: Add more parameter validation in RTAS time of day functions, David Gibson, 2015/02/05
- Re: [Qemu-devel] [Qemu-ppc] [PATCHv3 0/9] pseries: Fix and extend PAPR RTC implementation, Alexander Graf, 2015/02/09