diff mbox series

[v2,4/4] vl, qapi: offset value calculation in RTC_CHANGE event reverted to match behavior before #1797033 bugfix and documented

Message ID cf52eb15927d5517f9d525f6541b366a5b898af3.1539778764.git.artem.k.pisarenko@gmail.com (mailing list archive)
State New, archived
Headers show
Series Fix and improve core RTC function and documentation | expand

Commit Message

Artem Pisarenko Oct. 17, 2018, 12:23 p.m. UTC
Return value of qemu_timedate_diff(), used for calculation offset in QAPI 'RTC_CHANGE' event restored to keep compatibility, although it isn't documented that difference is relative to host clock advancement.
Added important note to 'RTC_CHANGE' event description to highlight established implementation specifics.

Signed-off-by: Artem Pisarenko <artem.k.pisarenko@gmail.com>
---
 qapi/misc.json |  3 ++-
 vl.c           | 10 +++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

Comments

Eric Blake Oct. 17, 2018, 2:01 p.m. UTC | #1
On 10/17/18 7:23 AM, Artem Pisarenko wrote:
> Return value of qemu_timedate_diff(), used for calculation offset in QAPI 'RTC_CHANGE' event restored to keep compatibility, although it isn't documented that difference is relative to host clock advancement.
> Added important note to 'RTC_CHANGE' event description to highlight established implementation specifics.
> 

Hmm, I just replied to v1 before seeing that you sent v2; my comments 
about long lines and a typo still apply.

> Signed-off-by: Artem Pisarenko <artem.k.pisarenko@gmail.com>
> ---
>   qapi/misc.json |  3 ++-
>   vl.c           | 10 +++++-----
>   2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/qapi/misc.json b/qapi/misc.json
> index ada9af5..ed866f2 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -3070,7 +3070,8 @@
>   # Emitted when the guest changes the RTC time.
>   #
>   # @offset: offset between base RTC clock (as specified by -rtc base), and
> -#          new RTC clock value
> +#          new RTC clock value. Note that value will be different depending
> +#          on clock choosen to drive RTC (specified by -rtc clock).
Artem Pisarenko Oct. 17, 2018, 2:36 p.m. UTC | #2
I fixed them and ready to submit v3.
Anything else ?

ср, 17 окт. 2018 г. в 20:01, Eric Blake <eblake@redhat.com>:

> On 10/17/18 7:23 AM, Artem Pisarenko wrote:
> > Return value of qemu_timedate_diff(), used for calculation offset in
> QAPI 'RTC_CHANGE' event restored to keep compatibility, although it isn't
> documented that difference is relative to host clock advancement.
> > Added important note to 'RTC_CHANGE' event description to highlight
> established implementation specifics.
> >
>
> Hmm, I just replied to v1 before seeing that you sent v2; my comments
> about long lines and a typo still apply.
>
> > Signed-off-by: Artem Pisarenko <artem.k.pisarenko@gmail.com>
> > ---
> >   qapi/misc.json |  3 ++-
> >   vl.c           | 10 +++++-----
> >   2 files changed, 7 insertions(+), 6 deletions(-)
> >
> > diff --git a/qapi/misc.json b/qapi/misc.json
> > index ada9af5..ed866f2 100644
> > --- a/qapi/misc.json
> > +++ b/qapi/misc.json
> > @@ -3070,7 +3070,8 @@
> >   # Emitted when the guest changes the RTC time.
> >   #
> >   # @offset: offset between base RTC clock (as specified by -rtc base),
> and
> > -#          new RTC clock value
> > +#          new RTC clock value. Note that value will be different
> depending
> > +#          on clock choosen to drive RTC (specified by -rtc clock).
> --
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3266 <(919)%20301-3266>
> Virtualization:  qemu.org | libvirt.org
>
diff mbox series

Patch

diff --git a/qapi/misc.json b/qapi/misc.json
index ada9af5..ed866f2 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -3070,7 +3070,8 @@ 
 # Emitted when the guest changes the RTC time.
 #
 # @offset: offset between base RTC clock (as specified by -rtc base), and
-#          new RTC clock value
+#          new RTC clock value. Note that value will be different depending
+#          on clock choosen to drive RTC (specified by -rtc clock).
 #
 # Note: This event is rate-limited.
 #
diff --git a/vl.c b/vl.c
index 78a8a68..c350aba 100644
--- a/vl.c
+++ b/vl.c
@@ -788,10 +788,10 @@  void qemu_system_vmstop_request(RunState state)
 
 /***********************************************************/
 /* RTC reference time/date access */
-static time_t qemu_ref_timedate(void)
+static time_t qemu_ref_timedate(QEMUClockType clock)
 {
-    time_t value = qemu_clock_get_ms(rtc_clock) / 1000;
-    switch (rtc_clock) {
+    time_t value = qemu_clock_get_ms(clock) / 1000;
+    switch (clock) {
     case QEMU_CLOCK_REALTIME:
         value -= rtc_realtime_clock_offset;
         /* no break */
@@ -811,7 +811,7 @@  static time_t qemu_ref_timedate(void)
 
 void qemu_get_timedate(struct tm *tm, int offset)
 {
-    time_t ti = qemu_ref_timedate();
+    time_t ti = qemu_ref_timedate(rtc_clock);
 
     ti += offset;
 
@@ -849,7 +849,7 @@  int qemu_timedate_diff(struct tm *tm)
         break;
     }
 
-    return seconds - qemu_ref_timedate();
+    return seconds - qemu_ref_timedate(QEMU_CLOCK_HOST);
 }
 
 static void configure_rtc_base_datetime(const char *startdate)