Hi Phil,

Thanks for an excellent explanation.

Follow up question - " ...additional clock source named "kvmclock",
which uses the host clock and the TSC: The host exports its current system
time (plus some configurable offset) and a snapshot value of TSC register
when doing so. Than the guest can interpolate the current time by using the
exported_system_time + scale * (current_TSC_value-snapshot_TSC_value).
This kvmclock doesn't have anything to do with the RTC clock as far as I
know."

Question: Since I am changing time on host using "date --set ...", it should
change
the value of the host clock, no? My question was since the host clock is
changed,
by the above logic, why is the guest clock also not changing?

My current source is kvmclock.

Thanks
-a

On Tue, Sep 13, 2011 at 2:49 AM, Philipp Hahn <h...@univention.de> wrote:

> Hello Al,
>
> I just debugged a kvmclock bug, so I claim to have some knowledge in this
> area
> now, but please take my answer with a grain of doubt.
>
> On Monday 12 September 2011 15:21:25 al pat wrote:
> > Still seeking your guidance on this. Appreciate any pointers you may
> have.
>
> You have to distiguish between the real-time-clock (RTC), which in hardware
> is
> a battery powered clock running even when your PC is powered off. Since
> it's
> slow to access, most Linux distributions read out its value once during
> boot
> using "hwclock --hctosys --utc" and than don't care about that clock any
> more
> until shutdown, when they write back the system time to the RTC
> using "... --systohc ...".
> During runtime, other methods are used for time keeping: Either by counting
> regular interrupts, using the ACPI-PM clock, or the High Performance Event
> Timer (HPET), or the Time Stamp Counter (TSC) register, or ...;
> see /sys/devices/system/clocksource/clocksource0/available_clocksource for
> a
> list of available clock sources.
>
> For virtual machines there is an additional clock source named "kvmclock",
> which uses the host clock and the TSC: The host exports its current system
> time (plus some configurable offset) and a snapshot value of TSC register
> when doing so. Than the guest can interpolate the current time by using the
> exported_system_time + scale * (current_TSC_value-snapshot_TSC_value). This
> kvmclock doesn't have anything to do with the RTC clock as far as I know.
>
> Now to your problem: You should check the value
> of /sys/devices/system/clocksource/clocksource0/current_clocksource in your
> guest. If it is somethong other than kvmclock, you should if
> using "hwclock --hctosys --utc" re-synchronizes your guest clock to the
> host.
>
> Sincerely
> Philipp
> --
> Philipp Hahn           Open Source Software Engineer
> h...@univention.de
> Univention GmbH        Linux for Your Business        fon: +49 421 22 232-
> 0
> Mary-Somerville-Str.1  D-28359 Bremen                 fax: +49 421 22
> 232-99
>
> http://www.univention.de/
>
> ----------------------------------------------------------------------------
> Treffen Sie Univention auf der IT&Business vom 20. bis 22. September 2011
> auf dem Gemeinschaftsstand der Open Source Business Alliance in Stuttgart
> in
> Halle 3 Stand 3D27-7.
>

Reply via email to