Bug 979333 - RHEL6.4 guest hardware time not correct after stop/cont
RHEL6.4 guest hardware time not correct after stop/cont
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
7.0
Unspecified Unspecified
medium Severity high
: rc
: ---
Assigned To: Marcelo Tosatti
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-28 05:05 EDT by ShupingCui
Modified: 2013-07-11 18:49 EDT (History)
10 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-07-05 15:45:19 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description ShupingCui 2013-06-28 05:05:26 EDT
Description of problem:
RHEL6.4 guest hardware time not correct after stop/cont

Version-Release number of selected component (if applicable):
host:
kernel-3.10.0-0.rc4.59.el7.x86_64
qemu-kvm-1.5.0-2.el7.x86_64
guest:
kernel-2.6.32-358.14.1.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. boot the guest with "-rtc base=utc,clock=vm"
/usr/libexec/qemu-kvm \
    -name 'vm1' \
    -chardev socket,id=serial_id_serial1,path=/tmp/serial-serial1-20130621-100435-VZyl373p,server,nowait \
    -device isa-serial,chardev=serial_id_serial1 \
    -chardev socket,id=seabioslog_id_20130621-100435-VZyl373p,path=/tmp/seabios-20130621-100435-VZyl373p,server,nowait \
    -device isa-debugcon,chardev=seabioslog_id_20130621-100435-VZyl373p,iobase=0x402 \
    -device ich9-usb-uhci1,id=usb1,bus=pci.0,addr=0x4 \
    -drive file='/root/staf-kvm-devel/autotest-devel/client/tests/virt/shared/data/images/RHEL-Server-6.4-64-virtio.qcow2',if=none,id=drive-virtio-disk1,media=disk,cache=none,snapshot=off,format=qcow2,aio=native \
    -device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk1 \
    -net none \
    -m 4096 \
    -smp 2,maxcpus=2,cores=1,threads=1,sockets=2 \
    -cpu 'Nehalem' \
    -M pc \
    -device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1 \
    -vnc :0 \
    -vga cirrus \
    -rtc base=utc,clock=vm,driftfix=slew  \
    -boot order=cdn,once=c,menu=off   \
    -no-kvm-pit-reinjection \
    -enable-kvm \
    -monitor stdio
2. check time in guest
# date
Fri Jun 28 16:57:45 CST 2013
# hwclock
Fri 28 Jun 2013 04:57:46 PM CST  -0.994255 seconds
3. stop guest
4. wait 2 mins, then cont
5. check time in guest
# date
Fri Jun 28 16:59:56 CST 2013
# hwclock
Fri 28 Jun 2013 04:57:47 PM CST  -0.657350 seconds


Actual results:
the hardware time not count

Expected results:
the hardware time should be count

Additional info:
Comment 2 ShupingCui 2013-07-04 03:43:59 EDT
With QE understanding, in physical machine, rtc keeps a PC’s hardware clock stable while the PC is powered off. qemu emulate a physical machine, so i think guest hardware time should be count when guest is paused.

please fix me if I make anything wrong here.

Thanks
Comment 3 Marcelo Tosatti 2013-07-05 15:45:19 EDT
(In reply to ShupingCui from comment #2)
> With QE understanding, in physical machine, rtc keeps a PC’s hardware clock
> stable while the PC is powered off. qemu emulate a physical machine, so i
> think guest hardware time should be count when guest is paused.
> 
> please fix me if I make anything wrong here.
> 
> Thanks

Correct but you are using clock=vm, whose behaviour as described in the qemu man page:

By default the RTC is driven by the host system time. This allows to use the RTC as accurate reference clock inside the guest, specifically if
the host time is smoothly following an accurate external reference clock, e.g. via NTP.  If you want to isolate the guest time from the host,
you can set clock to "rt" instead.  To even prevent it from progressing during suspension, you can set it to "vm".

So the RTC clock should count if clock=host. Closing as not a bug (please open a different bug if behaviour differs from what expected).

Thanks
Comment 4 ShupingCui 2013-07-10 07:13:55 EDT

(In reply to Marcelo Tosatti from comment #3)
> (In reply to ShupingCui from comment #2)
> > With QE understanding, in physical machine, rtc keeps a PC’s hardware clock
> > stable while the PC is powered off. qemu emulate a physical machine, so i
> > think guest hardware time should be count when guest is paused.
> > 
> > please fix me if I make anything wrong here.
> > 
> > Thanks
> 
> Correct but you are using clock=vm, whose behaviour as described in the qemu
> man page:
> 
According to your comments.If set clock=vm, the guest system time should not be affected. However, I find the rhel7.0 guest can be synced to host time after reboot. The details of steps as blew.
1. boot guest with -rtc base=utc,clock=vm -net none
2. modify guest time
3. reboot the guest

Restults:
Guest system time is synced to host.

Expect result.
Guest time should not be affected.
Comment 5 Marcelo Tosatti 2013-07-10 20:53:40 EDT
The man page says: 

"To even prevent it from progressing during suspension, you can set it to "vm"."

"If you want to isolate the guest time from the host, you can set clock to "rt" instead."

I suppose what you are expecting with the test case above in comment 4 is clock=rt behavior?
Comment 6 ShupingCui 2013-07-11 00:02:50 EDT
(In reply to Marcelo Tosatti from comment #5)
> The man page says: 
> 
> "To even prevent it from progressing during suspension, you can set it to
> "vm"."
> 
> "If you want to isolate the guest time from the host, you can set clock to
> "rt" instead."
> 
> I suppose what you are expecting with the test case above in comment 4 is
> clock=rt behavior?

i tried the clock=rt,
1. boot guest with -rtc base=utc,clock=rt -net none
2. modify guest system time
  # date -s xx:xx:xx
3. reboot the guest

Restults:
Guest system time is same with host system time.

Expect result.
Guest system time should not be affected.

adding info:
rhel7 guest could not sync hardware clock to system time when rebooting guest
Comment 7 Marcelo Tosatti 2013-07-11 18:49:35 EDT
(In reply to ShupingCui from comment #6)
> (In reply to Marcelo Tosatti from comment #5)
> > The man page says: 
> > 
> > "To even prevent it from progressing during suspension, you can set it to
> > "vm"."
> > 
> > "If you want to isolate the guest time from the host, you can set clock to
> > "rt" instead."
> > 
> > I suppose what you are expecting with the test case above in comment 4 is
> > clock=rt behavior?
> 
> i tried the clock=rt,
> 1. boot guest with -rtc base=utc,clock=rt -net none
> 2. modify guest system time
>   # date -s xx:xx:xx
> 3. reboot the guest
> 
> Restults:
> Guest system time is same with host system time.
> 
> Expect result.
> Guest system time should not be affected.
> 
> adding info:
> rhel7 guest could not sync hardware clock to system time when rebooting guest

You should write guest system time to RTC with hwclock --set?

Note You need to log in before you can comment on or make changes to this bug.