From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIegI-0007EF-RI for qemu-devel@nongnu.org; Mon, 01 Oct 2012 08:01:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TIeg7-0006jh-Og for qemu-devel@nongnu.org; Mon, 01 Oct 2012 08:01:02 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:44793) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIeg7-0006ha-J5 for qemu-devel@nongnu.org; Mon, 01 Oct 2012 08:00:51 -0400 Received: by padfb10 with SMTP id fb10so4215265pad.4 for ; Mon, 01 Oct 2012 05:00:50 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <506985E9.1000002@redhat.com> Date: Mon, 01 Oct 2012 14:00:41 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <20120928172131.28971.43057.malonedeb@wampee.canonical.com> <20120928172131.28971.43057.malonedeb@wampee.canonical.com> In-Reply-To: <20120928172131.28971.43057.malonedeb@wampee.canonical.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Bug 1058225] [NEW] When setting hardware clock on linux guest, hwclock shows crazy date (in the year 2043) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bug 1058225 <1058225@bugs.launchpad.net> Cc: qemu-devel@nongnu.org, Lucas Meneghel Rodrigues Il 28/09/2012 19:21, Lucas Meneghel Rodrigues ha scritto: > Public bug reported: > > Very easy to reproduce: > > 1) Build the latest qemu.git (we've captured this on internal automated > testing, verified manually), the commit for reference is: > > 14:07:02 INFO | git commit ID is > 6f8fd2530e9a530f237240daf1c981fa5df7f978 (tag v1.2.0-461-g6f8fd25) > > 2) Install a linux guest in it (caught with RHEL 6.2, verified with > Fedora 17) > > 3) In the linux guest, set the hardware clock with hwclock: > > /sbin/hwclock --set --date "2/2/80 03:04:00" > > 4) Verify if hardware clock was set back to the eighties: > > LC_ALL=C /sbin/hwclock > > 5) Observe amazed that hwclock reports a date in the year 2043: > > 14:09:34 INFO | ('hwclock', 'FAIL', 2, "Failed to set hwclock > back to the eighties. Output of hwclock is 'Sun Dec 27 20:35:46 2043 > -0.489664 seconds'") I can reproduce this with qtest. The test is bogus. Linux (drivers/rtc/rtc-cmos.c) doesn't set the century byte, so it may fail if you set a date that is before 2000. Setting a date in 2011 works. However, there is of course a bug, which was latent so far and made visible by the recent algorithmic changes for the RTC. The strange date arises because you actually set the date to 2080. mktimegm (in cutils.c) has an year-2038 overflow. I'll send a patchset to fix this and implement the century byte correctly. Paolo