Bug 1461241 - [P9] Guest system time continue when stop the guest in hmp
[P9] Guest system time continue when stop the guest in hmp
Status: CLOSED CANTFIX
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
7.4-Alt
ppc64le Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: David Gibson
Xujun Ma
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-13 23:05 EDT by Xujun Ma
Modified: 2017-06-21 08:01 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-06-14 22:27:23 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 Xujun Ma 2017-06-13 23:05:18 EDT
Description of problem:
Guest system time continue when stop the guest in hmp

Version-Release number of selected component (if applicable):
host kernel:4.11.0-7.el7.test.ppc64le
guest kernel:4.11.0-5.el7.ppc64le


How reproducible:
100%

Steps to Reproduce:
1.Boot up gues with command:
/usr/libexec/qemu-kvm \
 -name vm \
 -smp 8 \
 -m 8192 \
 -rtc base=utc,clock=host \
 -chardev stdio,mux=on,id=serial_id_serial0,server,nowait \
 -device spapr-vty,id=serial111,chardev=serial_id_serial0 \
 -mon chardev=serial_id_serial0,mode=readline \
 -nodefaults \
 -device virtio-scsi-pci,bus=pci.0,addr=0x5 \
 -device scsi-hd,id=scsi-hd0,drive=scsi-hd-dr0,bootindex=1\
 -drive file=pegas.qcow2,if=none,id=scsi-hd-dr0,format=qcow2,cache=none \
 -device virtio-net-pci,netdev=net0,id=nic0,mac=70:e2:84:14:e7:84 \
 -netdev tap,id=net0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown,vhost=on 
2.Show time in guest,then stop the guest in hmp for a moment then resume the guest.
[root@localhost ~]# date
Tue Jun 13 22:57:12 EDT 2017
(qemu)stop
(qemu)c
#date
Tue Jun 13 22:59:21 EDT 2017
3.

Actual results:
Guest system time continue when stop the guest in hmp

Expected results:
Guest system time should stop when pause the guest in hmp

Additional info:
Comment 2 Laurent Vivier 2017-06-14 07:53:29 EDT
looks like BZ1264258, but it has been fixed by (included since v2.9.0):

commit 42043e4f1241eeb77f87f5816b5cf0b6e9583ed7
Author: Laurent Vivier <lvivier@redhat.com>
Date:   Fri Jan 27 13:24:58 2017 +0100

    spapr: clock should count only if vm is running
    
    This is a port to ppc of the i386 commit:
        00f4d64 kvmclock: clock should count only if vm is running
    
    We remove timebase_post_load function, and use the VM state
    change handler to save and restore the guest_timebase (on stop
    and continue).
    
    We keep timebase_pre_save to reduce the clock difference on
    migration like in:
        6053a86 kvmclock: reduce kvmclock difference on migration
    
    Time base offset has originally been introduced by commit
        98a8b52 spapr: Add support for time base offset migration
    
    So while VM is paused, the time is stopped. This allows to have
    the same result with date (based on Time Base Register) and
    hwclock (based on "get-time-of-day" RTAS call).
    
    Moreover in TCG mode, the Time Base is always paused, so this
    patch also adjust the behavior between TCG and KVM.
    
    VM state field "time_of_the_day_ns" is now useless but we keep
    it to be able to migrate to older version of the machine.
    
    As vmstate_ppc_timebase structure (with timebase_pre_save() and
    timebase_post_load() functions) was only used by vmstate_spapr,
    we register the VM state change handler only in ppc_spapr_init().
    
    Signed-off-by: Laurent Vivier <lvivier@redhat.com>
    Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Could you provide your qemu-kvm version?
Comment 3 Laurent Vivier 2017-06-14 07:57:21 EDT
you should use "clock=vm" if you want the clock stops.

See manual:

           By default the RTC is driven by the host system time. This allows
           using of 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".

Could you check with x86_64?
Comment 4 Xujun Ma 2017-06-14 20:23:16 EDT
(In reply to Laurent Vivier from comment #2)
> looks like BZ1264258, but it has been fixed by (included since v2.9.0):
> 
> commit 42043e4f1241eeb77f87f5816b5cf0b6e9583ed7
> Author: Laurent Vivier <lvivier@redhat.com>
> Date:   Fri Jan 27 13:24:58 2017 +0100
> 
>     spapr: clock should count only if vm is running
>     
>     This is a port to ppc of the i386 commit:
>         00f4d64 kvmclock: clock should count only if vm is running
>     
>     We remove timebase_post_load function, and use the VM state
>     change handler to save and restore the guest_timebase (on stop
>     and continue).
>     
>     We keep timebase_pre_save to reduce the clock difference on
>     migration like in:
>         6053a86 kvmclock: reduce kvmclock difference on migration
>     
>     Time base offset has originally been introduced by commit
>         98a8b52 spapr: Add support for time base offset migration
>     
>     So while VM is paused, the time is stopped. This allows to have
>     the same result with date (based on Time Base Register) and
>     hwclock (based on "get-time-of-day" RTAS call).
>     
>     Moreover in TCG mode, the Time Base is always paused, so this
>     patch also adjust the behavior between TCG and KVM.
>     
>     VM state field "time_of_the_day_ns" is now useless but we keep
>     it to be able to migrate to older version of the machine.
>     
>     As vmstate_ppc_timebase structure (with timebase_pre_save() and
>     timebase_post_load() functions) was only used by vmstate_spapr,
>     we register the VM state change handler only in ppc_spapr_init().
>     
>     Signed-off-by: Laurent Vivier <lvivier@redhat.com>
>     Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> 
> Could you provide your qemu-kvm version?

qemu-kvm-rhev-2.9.0-7.el7.ppc64le
Comment 5 Xujun Ma 2017-06-14 20:29:22 EDT
(In reply to Laurent Vivier from comment #3)
> you should use "clock=vm" if you want the clock stops.
As I know,It will make rtc time stop,not system time.
> 
> See manual:
> 
>            By default the RTC is driven by the host system time. This allows
>            using of 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".
> 
> Could you check with x86_64?
I have tested it on power8 host and x86 platform,and no this problem,so I think it's a power9 only bug.
Comment 6 David Gibson 2017-06-14 22:27:23 EDT
Xujun,

You're right that clock=vm should affect the RTC and not system time.

I believe this bug is a side effect of the workaround for bug 1451884.

Stopping the guest's clock requires adjusting its timebase offset.  But on POWER9 DD1, adjustimg the timebase offset can crash the host, so it is disabled.

There is nothing we can do to fix this until we get updated CPUs.

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