Red Hat Enterprise Linux 8 Essentials Book now available.
Purchase a copy of Red Hat Enterprise Linux 8 (RHEL 8) Essentials in eBook ($24.99) or Print ($36.99) format
Red Hat Enterprise Linux 8 Essentials Print and eBook (ePub/PDF/Kindle) editions contain 31 chapters and over 250 pages
24.11. Virtual machine timer management with libvirt
Accurate time keeping on virtualized guests is a key challenge for virtualization platforms. Different hypervisors attempt to handle the problem of time keeping in a variety of ways. Libvirt provides hypervisor independent configuration settings for time management, using the <clock> and <timer> elements in the domain XML. Note that not all options are supported for all hypervisors. The domain XML can be edited using the virsh edit command. See Editing a guest's configuration file for details.
The clock element is used to determine how the guest clock is synchronized with the host clock. The clock element has the following attributes:
Determines how the guest clock is offset from the host clock. The offset attribute has the following possible values:
Table 24.1. Offset attribute values
The guest clock will be synchronized to UTC when booted.
The guest clock will be synchronized to the host's configured timezone when booted, if any.
The guest clock will be synchronized to a given timezone, specified by the timezone attribute.
The guest clock will be synchronized to an arbitrary offset from UTC. The delta relative to UTC is specified in seconds, using the adjustment attribute. The guest is free to adjust the Real Time Clock (RTC) over time and expect that it will be honored following the next reboot. This is in contrast to utc mode, where any RTC adjustments are lost at each reboot.
The timezone to which the guest clock is to be synchronized.
The delta for guest clock synchronization. In seconds, relative to UTC.
Example 24.1. Always synchronize to UTC
<clock offset="utc" />
Example 24.2. Always synchronize to the host timezone
<clock offset="localtime" />
Example 24.3. Synchronize to an arbitrary timezone
Example 24.4. Synchronize to UTC + arbitrary offset
<clock offset="variable" adjustment="123456" />
A clock element can have zero or more timer elements as children. The timer element specifies a time source used for guest clock synchronization. The timer element has the following attributes. Only the name is required, all other attributes are optional.
The name of the time source to use.
Table 24.2. name attribute values
The master virtual time source which may be used to drive the policy of other time sources.
Programmable Interval Timer - a timer with periodic interrupts.
Real Time Clock - a continuously running timer with periodic interrupts.
High Precision Event Timer - multiple timers with periodic interrupts.
Time Stamp Counter - counts the number of ticks since reset, no interrupts.
Specifies whether the wallclock should track host or guest time. Only valid for a name value of platform or rtc.
Table 24.3. wallclock attribute values
RTC wallclock always tracks host time.
RTC wallclock always tracks guest time.
The policy used to pass ticks on to the guest.
Table 24.4. tickpolicy attribute values
Continue to deliver at normal rate (i.e. ticks are delayed).
Deliver at a higher rate to catch up.
Ticks merged into one single tick.
All missed ticks are discarded.
Used to set a fixed frequency, measured in Hz. This attribute is only relevant for a name value of tsc. All other timers operate at a fixed frequency (pit, rtc), or at a frequency fully controlled by the guest (hpet).
Determines how the time source is exposed to the guest. This attribute is only relevant for a name value of tsc. All other timers are always emulated.
Table 24.5. mode attribute values
Native if safe, otherwise emulated.
Native + para-virtualized.
Used to override the default set of timers visible to the guest. For example, to enable or disable the HPET.
Table 24.6. present attribute values
Force this timer to the visible to the guest.
Force this timer to not be visible to the guest.
Example 24.5. Clock synchronizing to local time with RTC and PIT timers, and the HPET timer disabled