qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [Bug 1058225] [NEW] When setting hardware clock on linux guest, hwclock shows crazy date (in the year 2043)
@ 2012-09-28 17:21 Lucas Meneghel Rodrigues
  2012-10-01 12:00 ` Paolo Bonzini
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lucas Meneghel Rodrigues @ 2012-09-28 17:21 UTC (permalink / raw)
  To: qemu-devel

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'")

** Affects: qemu
     Importance: Undecided
         Status: New


** Tags: kvmclock

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1058225

Title:
  When setting hardware clock on linux guest, hwclock shows crazy date
  (in the year 2043)

Status in QEMU:
  New

Bug description:
  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'")

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1058225/+subscriptions

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [Bug 1058225] [NEW] When setting hardware clock on linux guest, hwclock shows crazy date (in the year 2043)
  2012-09-28 17:21 [Qemu-devel] [Bug 1058225] [NEW] When setting hardware clock on linux guest, hwclock shows crazy date (in the year 2043) Lucas Meneghel Rodrigues
@ 2012-10-01 12:00 ` Paolo Bonzini
  2012-10-16 15:01 ` [Qemu-devel] [Bug 1058225] " Lucas Meneghel Rodrigues
  2013-05-20 17:35 ` Aurelien Jarno
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2012-10-01 12:00 UTC (permalink / raw)
  To: Bug 1058225; +Cc: qemu-devel, 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [Bug 1058225] Re: When setting hardware clock on linux guest, hwclock shows crazy date (in the year 2043)
  2012-09-28 17:21 [Qemu-devel] [Bug 1058225] [NEW] When setting hardware clock on linux guest, hwclock shows crazy date (in the year 2043) Lucas Meneghel Rodrigues
  2012-10-01 12:00 ` Paolo Bonzini
@ 2012-10-16 15:01 ` Lucas Meneghel Rodrigues
  2013-05-20 17:35 ` Aurelien Jarno
  2 siblings, 0 replies; 4+ messages in thread
From: Lucas Meneghel Rodrigues @ 2012-10-16 15:01 UTC (permalink / raw)
  To: qemu-devel

Paolo fixed the problem with upstream commit:

commit b6db4aca20e9af4f62c9c9e08b9b9672a6ed3390
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Mon Oct 1 14:22:06 2012 +0200

    rtc: fix overflow in mktimegm
    
    When setting a date in 1980, Linux is actually disregarding the century
    byte and setting the year to 2080.  This causes a year-2038 overflow
    in mktimegm.  Fix this by doing the days-to-seconds computation in
    64-bit math.
    
    Reported-by: Lucas Meneghel Rodrigues <lookkas@gmail.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Confirmed that problem is solved. Closing bug.

** Changed in: qemu
       Status: New => Confirmed

** Changed in: qemu
       Status: Confirmed => Fix Committed

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1058225

Title:
  When setting hardware clock on linux guest, hwclock shows crazy date
  (in the year 2043)

Status in QEMU:
  Fix Committed

Bug description:
  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'")

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1058225/+subscriptions

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [Bug 1058225] Re: When setting hardware clock on linux guest, hwclock shows crazy date (in the year 2043)
  2012-09-28 17:21 [Qemu-devel] [Bug 1058225] [NEW] When setting hardware clock on linux guest, hwclock shows crazy date (in the year 2043) Lucas Meneghel Rodrigues
  2012-10-01 12:00 ` Paolo Bonzini
  2012-10-16 15:01 ` [Qemu-devel] [Bug 1058225] " Lucas Meneghel Rodrigues
@ 2013-05-20 17:35 ` Aurelien Jarno
  2 siblings, 0 replies; 4+ messages in thread
From: Aurelien Jarno @ 2013-05-20 17:35 UTC (permalink / raw)
  To: qemu-devel

** Changed in: qemu
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1058225

Title:
  When setting hardware clock on linux guest, hwclock shows crazy date
  (in the year 2043)

Status in QEMU:
  Fix Released

Bug description:
  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'")

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1058225/+subscriptions

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-05-20 17:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-28 17:21 [Qemu-devel] [Bug 1058225] [NEW] When setting hardware clock on linux guest, hwclock shows crazy date (in the year 2043) Lucas Meneghel Rodrigues
2012-10-01 12:00 ` Paolo Bonzini
2012-10-16 15:01 ` [Qemu-devel] [Bug 1058225] " Lucas Meneghel Rodrigues
2013-05-20 17:35 ` Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).