Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 320

kvm-83-270.el5_11.src.rpm

From ee7570cb1fbe975c9e9be15769b82bd8e0cd24a2 Mon Sep 17 00:00:00 2001
From: Gleb Natapov <gleb@redhat.com>
Date: Wed, 9 Nov 2011 09:31:24 +0100
Subject: [PATCH] do not change RTC stored time accidentally

RH-Author: Gleb Natapov <gleb@redhat.com>
Message-id: <20111109093124.GR3225@redhat.com>
Patchwork-id: 34939
O-Subject: [PATCH RHEL5.8 qemu] do not change RTC stored time accidentally
Bugzilla: 703335
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Rik van Riel <riel@redhat.com>

mktime() modifies its argument. Do not call it on RTC data directly.

BZ: 703335
Upstream: f54c556c08c57a317ad54f5d2d9ad549b931cda2

Signed-off-by: Gleb Natapov <gleb@redhat.com>
--
			Gleb.

Signed-off-by: Michal Novotny <mignov@gmail.com>
---
 qemu/hw/mc146818rtc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/qemu/hw/mc146818rtc.c b/qemu/hw/mc146818rtc.c
index bf99c05..0818eb7 100644
--- a/qemu/hw/mc146818rtc.c
+++ b/qemu/hw/mc146818rtc.c
@@ -285,12 +285,15 @@ static void rtc_set_time(RTCState *s)
     tm->tm_year = from_bcd(s, s->cmos_data[RTC_YEAR]) + 100;
     {   /* notify monitoring software of the change */
         time_t rtc_ti;
+        struct tm tmp;
 
         /* rtc_utc is now declared static. just assume -localtime */
         /* if (rtc_utc)
             rtc_ti = timegm(tm);
         else */
-            rtc_ti = mktime(tm);
+            tmp = *tm;
+            tmp.tm_isdst = -1; /* use timezone to figure it out */
+            rtc_ti = mktime(&tmp);
             term_printf_async(RTC_ASYNC_EVENT,
 			      "RTC: new time is UTC%+ld\n",
                               (long)(rtc_ti - time(NULL)));
-- 
1.7.4.4