Bug 981242

Summary: guest hardware time should be count when guest is paused
Product: Red Hat Enterprise Linux 6 Reporter: ShupingCui <scui>
Component: qemu-kvmAssignee: Marcelo Tosatti <mtosatti>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.5CC: acathrow, bsarathy, chayang, fyang, huding, juzhang, michen, mkenneth, qzhang, scui, shuang, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-08-02 15:37:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description ShupingCui 2013-07-04 10:02:12 UTC
Description of problem:
guest hardware time cannot be count when guest is paused

Version-Release number of selected component (if applicable):
host:
kernel-2.6.32-392.el6.x86_64
qemu-kvm-0.12.1.2-2.377.el6.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-20130702-093138-pSivbSG8,server,nowait \
    -device isa-serial,chardev=serial_id_serial1 \
    -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 1,maxcpus=1,cores=1,threads=1,sockets=2 \
    -cpu 'Penryn' \
    -M rhel6.5.0 \
    -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
Thu Jul  4 17:49:22 CST 2013
# hwclock
Thu 04 Jul 2013 05:49:23 PM CST  -0.991541 seconds

3. stop guest
4. wait 2 mins, then cont
5. check time in guest
# date
Thu Jul  4 17:51:22 CST 2013
# hwclock
Thu 04 Jul 2013 05:49:24 PM CST  -0.266206 seconds


Actual results:
the system clock be count, the hardware time not count

Expected results:
the hardware time should be count when guest is paused

Additional info:
1. i tried boot the guest with "-rtc base=utc,clock=host,driftfix=slew"
after stop/cont, the guest hardware clock is count when guest is paused

2. host cpuinfo
processor	: 1
vendor_id	: GenuineIntel
cpu family	: 6
model		: 23
model name	: Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
stepping	: 10
cpu MHz		: 2992.051
cache size	: 6144 KB
physical id	: 0
siblings	: 2
core id		: 1
cpu cores	: 2
apicid		: 1
initial apicid	: 1
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dts tpr_shadow vnmi flexpriority
bogomips	: 5984.10
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

Comment 1 ShupingCui 2013-07-04 10:05:47 UTC
in guest:
# cat /sys/devices/system/clocksource/clocksource0/current_clocksource
kvm-clock

Comment 3 Marcelo Tosatti 2013-08-01 17:32:04 UTC
(In reply to ShupingCui from comment #1)
> in guest:
> # cat /sys/devices/system/clocksource/clocksource0/current_clocksource
> kvm-clock

Shuping Cui, 

The RTC clock not counting on vmpause is expected behaviour with clock=vm, as
described by 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".
"

Can you please confirm the software is behaving as expected, or point to the problem? Thanks.

Comment 4 ShupingCui 2013-08-02 10:02:50 UTC
(In reply to Marcelo Tosatti from comment #3)
> (In reply to ShupingCui from comment #1)
> > in guest:
> > # cat /sys/devices/system/clocksource/clocksource0/current_clocksource
> > kvm-clock
> 
> Shuping Cui, 
> 
> The RTC clock not counting on vmpause is expected behaviour with clock=vm, as
> described by 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".
> "
> 
> Can you please confirm the software is behaving as expected, or point to the
> problem? Thanks.

Hi Marcelo,

ok, you're right, the guest RTC clock only count when clock=host, 

thanks for your help.

Best Regards,
Shuping