libvirt KVM driver need special timer policy settings for reliable guest time keeping

Bug #1011848 reported by Daniel Berrange
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Daniel Berrange

Bug Description

There are a number of emulated timers presented to KVM virtual machines, the most important of which are the PIT and the RTC. Unfortunately the default KVM/QEMU policies for these timers is sub-optimal, raising potential for BSOD in Windows 7 guests and time drift in old Linux guests (those with kernels lacking KVM clock). To address this, Nova needs to set a couple of custom policies for KVM guests. The following XML can be used

      <clock offset='utc'>
        <timer name='pit' tickpolicy='delay'/>
        <timer name='rtc' tickpolicy='catchup'/>
      </clock>

Which corresponds the following KVM options

      -no-kvm-pit-reinjection
      -rtc base=utc,driftfix=slew

The PIT and RTC settings are required for Linux guests, and the RTC setting is required for Windows guests. The PIT setting should not adversely affect Windows guest, so it is reasonable at this point to set both settings for all guests. In the future this ought to be configurable per guest OS type and disk images identified by OS type somehow.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/8422

Changed in nova:
assignee: nobody → Daniel Berrange (berrange)
status: New → In Progress
Revision history for this message
Pádraig Brady (p-draigbrady) wrote :

I'm wondering why the default KVM/QEMU are "sub-optimal".
Is it for maximum guest compatability which we don't need,
or that the defaults are changing in newer versions and this
just ensures appropriate defaults on older versions?

Revision history for this message
Daniel Berrange (berrange) wrote :

I believe it is due to a combination of historical precedent existing defaults, and the difference in needs between plain QEMU vs KVM. My patch is only changing it for KVM enabled guests. There has been recent talk of updating KVM defaults upstream, but so far it hasn't gone anywhere productive. The settings I'm proposing here are based on recommendations from Red Hat KVM maintainers, and have been used in RHEV-M/oVirt since RHEL-5 KVM vintage.

Revision history for this message
Mark McLoughlin (markmc) wrote :

There have been many "discussions" over the years about where sane defaults like this should live. The result of the stalemate means that it's up to the applications themselves to set these defaults.

The tenuous grasp I had on this timer stuff in the past is now a distant memory, but here are some references that might help interested folks:

http://libvirt.org/formatdomain.html#elementsTime
http://www.redhat.com/archives/libvir-list/2010-March/msg00304.html
http://lists.gnu.org/archive/html/qemu-devel/2012-01/msg02596.html
https://bugzilla.redhat.com/show_bug.cgi?id=507834#c13

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/8422
Committed: http://github.com/openstack/nova/commit/3114a97ba188895daff4a3d337b2c73855d4632d
Submitter: Jenkins
Branch: master

commit 3114a97ba188895daff4a3d337b2c73855d4632d
Author: Daniel P. Berrange <email address hidden>
Date: Mon Jun 11 17:16:10 2012 +0100

    Update default policies for KVM guest PIT & RTC timers

    The default policies for the KVM guest PIT and RTC timers
    are not very good at maintaining reliable time in guest
    operating systems. In particular Windows 7 guests will
    often crash with the default KVM timer policies, and old
    Linux guests will have very bad time drift

    Set the PIT such that missed ticks are injected at the
    normal rate, ie they are delayed

    Set the RTC such that missed ticks are injected at a
    higher rate to "catch up"

    This corresponds to the following libvirt XML

      <clock offset='utc'>
        <timer name='pit' tickpolicy='delay'/>
        <timer name='rtc' tickpolicy='catchup'/>
      </clock>

    And the following KVM options

      -no-kvm-pit-reinjection
      -rtc base=utc,driftfix=slew

    This should provide a default configuration that works
    acceptably for most OS types. In the future this will
    likely need to be made configurable per-guest OS type.

    Fixes LP bug #1011848

    Change-Id: Iafb0e2192b5f3c05b6395ffdfa14f86a98ce3d1f
    Signed-off-by: Daniel P. Berrange <email address hidden>

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → folsom-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: folsom-2 → 2012.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.