Bug 998109

Summary: Let's enable kvmclock in RHEL 7
Product: Red Hat Enterprise Linux 7 Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: bfan, leiwang, lkong, rjones, walters, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.22.6-12.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 998108 Environment:
Last Closed: 2014-06-13 10:22:00 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:
Bug Depends On: 998108    
Bug Blocks:    

Description Richard W.M. Jones 2013-08-17 09:37:21 UTC
+++ This bug was initially created as a clone of Bug #998108 +++

+++ This bug was initially created as a clone of Bug #998065 +++

Upstream we switched over to using kvmclock (038ed0a08e & c53b459fdd).
We should do so in RHEL too since it would avoid most of
the trouble with clock instability.

https://github.com/libguestfs/libguestfs/commit/038ed0a08eaed33e62a27c9f91780a25de0bc08c
https://github.com/libguestfs/libguestfs/commit/c53b459fdd7fc340f48a76496b7e7e18256a2d64

Comment 3 Richard W.M. Jones 2013-10-03 14:22:22 UTC
Turns out we need:
216cb004aef8ad6cb554ecdb9d7c4eb7634fe678
otherwise libvirt doesn't actually enable kvmclock.

Comment 4 Richard W.M. Jones 2013-10-16 18:56:19 UTC
libguestfs-1.22.6-12.el7
http://brewweb.devel.redhat.com/brew/taskinfo?taskID=6429251

Comment 5 Lingfei Kong 2014-01-28 04:45:01 UTC
Hi Rich,
I try to verify this bug with libguestfs-1.22.6-18.el7 according the steps recorded in https://bugzilla.redhat.com/show_bug.cgi?id=998108#c2 :

[root@rhel7libguestfs ~]# guestfish -x -v -N fs > boot.log 2>&1
[root@rhel7libguestfs ~]# cat boot.log | grep -Ei "kvmclock|kvm-clock"
libguestfs: libvirt XML:\n<?xml version="1.0"?>\n<domain type="kvm" xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0">\n  <name>guestfs-m8wwuh1utchd0hnb</name>\n  <memory unit="MiB">500</memory>\n  <currentMemory unit="MiB">500</currentMemory>\n  <cpu mode="host-passthrough">\n    <model fallback="allow"/>\n  </cpu>\n  <vcpu>1</vcpu>\n  <clock offset="utc">\n    <timer name="kvmclock" present="yes"/>\n  </clock>\n  <os>\n    <type>hvm</type>\n    <kernel>/var/tmp/.guestfs-0/kernel.9501</kernel>\n    <initrd>/var/tmp/.guestfs-0/initrd.9501</initrd>\n    <cmdline>panic=1 console=ttyS0 udevtimeout=600 no_timer_check acpi=off printk.time=1 cgroup_disable=memory root=/dev/sdb selinux=0 guestfs_verbose=1 TERM=xterm</cmdline>\n  </os>\n  <on_reboot>destroy</on_reboot>\n  <devices>\n    <controller type="scsi" index="0" model="virtio-scsi"/>\n    <disk device="disk" type="file">\n      <source file="/root/test1.img"/>\n      <target dev="sda" bus="scsi"/>\n      <driver name="qemu" type="raw" cache="writeback"/>\n      <address type="drive" controller="0" bus="0" target="0" unit="0"/>\n    </disk>\n    <disk type="file" device="disk">\n      <source file="/tmp/libguestfsvzQGi1/snapshot1"/>\n      <target dev="sdb" bus="scsi"/>\n      <driver name="qemu" type="qcow2" cache="unsafe"/>\n      <address type="drive" controller="0" bus="0" target="1" unit="0"/>\n      <shareable/>\n    </disk>\n    <serial type="unix">\n      <source mode="connect" path="/tmp/libguestfsvzQGi1/console.sock"/>\n      <target port="0"/>\n    </serial>\n    <channel type="unix">\n      <source mode="connect" path="/tmp/libguestfsvzQGi1/guestfsd.sock"/>\n      <target type="virtio" name="org.libguestfs.channel.0"/>\n    </channel>\n  </devices>\n  <qemu:commandline>\n    <qemu:env name="TMPDIR" value="/var/tmp"/>\n  </qemu:commandline>\n</domain>\n

---------------------------------------------------------------------------------
But I can not find such lines in  boot.log:
"     -cpu host,+kvmclock \
    ...
    kvm-clock: Using msrs 4b564d01 and 4b564d00
    kvm-clock: cpu 0, msr 0:1c247c1, boot clock
    kvm-clock: cpu 0, msr 0:22167c1, primary cpu clock
    [    0.381003] Switching to clocksource kvm-clock
"'

Is there anything wrong with my steps? How can I make sure kvmclock is enabled in rhel7 and works well? 

Thanks and Best Regards,
Lingfei Kong

Comment 6 Richard W.M. Jones 2014-01-28 08:52:57 UTC
A few points:

(1) "-cpu host,+kvmclock" is NOT necessary to enable kvm-clock.
It is enabled by default for KVM guests.

(2) You SHOULD see:
    Switching to clocksource kvm-clock
during boot.

(3) If you are testing this inside a RHEL 7 VM, it won't work.  kvm-clock
is only enabled for KVM guests, not for TCG guests.

Do you see another clocksource mentioned in the output of
libguestfs-test-tool?

Comment 7 bfan 2014-01-28 09:18:05 UTC
(In reply to Richard W.M. Jones from comment #6)
> A few points:
> 
> (1) "-cpu host,+kvmclock" is NOT necessary to enable kvm-clock.
> It is enabled by default for KVM guests.
> 
> (2) You SHOULD see:
>     Switching to clocksource kvm-clock
> during boot.
> 
> (3) If you are testing this inside a RHEL 7 VM, it won't work.  kvm-clock
> is only enabled for KVM guests, not for TCG guests.
> 
> Do you see another clocksource mentioned in the output of
> libguestfs-test-tool?

Thanks, Rich, saw the "Switching to clocksource kvm-clock"

# cat libguestfs-test-tool.log | grep kvm-clock
[    0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00
[    0.000000] kvm-clock: cpu 0, msr 0:1f071001, boot clock
[    0.000000] kvm-clock: cpu 0, msr 0:1f071001, primary cpu clock
[    0.377039] Switching to clocksource kvm-clock

Package version:
libguestfs-1.22.6-18.el7.x86_64
libvirt-1.1.1-19.el7.x86_64

So, verified this bug.

Comment 8 Ludek Smid 2014-06-13 10:22:00 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.