libvirt/src/qemu
Laine Stump cde8ca2dfd qemu: fix <clock offset='variable' basis='localtime'/>
For a clock element as above, libvirt simply converts current system
time with localtime_r(), then starts qemu with a time string that
doesn't contain any timezone information. So, from qemu's point of
view, the -rtc string it gets for:

   <clock offset='variable' basis='utc' adjustment='10800'/>

is identical to the -rtc string it gets for:

   <clock offset='variable' basis='localtime' adjustment='0'/>

(assuming the host is in a timezone that is 10800 seconds ahead of
UTC, as is the case on the machine where this message is being
written).

Since the commandlines are identical, qemu will behave identically
after this point in either case.

There are two problems in the case of basis='localtime' though:

Problem 1) If the guest modifies its RTC, for example to add 20
seconds, the RTC_CHANGE event from qemu will then contain offset:20 in
both cases. But libvirt will have saved the original adjustment into
adjustment0, and will add that value onto the offset in the
event. This means that in the case of basis=;utc', it will properly
emit an event with offset:10820, but in the case of basis='localtime'
the event will contain offset:20, which is *not* the new offset of the
RTC from UTC (as the event it documented to provide).

Problem 2) If the guest is migrated to another host that is in a
different timezone, or if it is migrated or saved/restored after the
DST status has changed from what it was when the guest was originally
started, the newly restarted guest will have a different RTC (since it
will be based on the new localtime, which could have shifted by
several hours).

The solution to both of these problems is simple - rather than
maintaining the original adjustment value along with
"basis='localtime'" in the domain status, when the domain is started
we convert the adjustment offset to one relative to UTC, and set the
status to "basis='utc'". Thus, whatever the RTC offset was from UTC
when it was initially started, that offset will be maintained when
migrating across timezones and DST settings, and the RTC_CHANGE events
will automatically contain the proper offset (which should by
definition always be relative to UTC).

This fixes a problem that was implied but not openly stated in:

  https://bugzilla.redhat.com/show_bug.cgi?id=964177
2014-05-26 13:59:32 +03:00
..
libvirtd_qemu.aug migration: add support for migrateURI configuration 2014-05-20 13:13:29 +02:00
MIGRATION.txt qemu: Implement migration job phases 2011-07-27 08:45:09 -06:00
qemu_agent.c avoid 'sync' as variable name 2014-05-19 18:40:02 +02:00
qemu_agent.h qemu: Implement virDomain{Get,Set}Time 2014-05-15 16:44:45 +02:00
qemu_capabilities.c Add support for timestamping QEMU logs 2014-05-07 10:27:50 +02:00
qemu_capabilities.h Add support for timestamping QEMU logs 2014-05-07 10:27:50 +02:00
qemu_cgroup.c qemuSetupCgroupForVcpu: s/virProcessInfoSetAffinity/virProcessSetAffinity/ 2014-05-22 12:30:20 +02:00
qemu_cgroup.h Auto-detect existing cgroup placement 2013-07-23 22:46:31 +01:00
qemu_command.c qemu: fix <clock offset='variable' basis='localtime'/> 2014-05-26 13:59:32 +03:00
qemu_command.h qemu: extract common PCI handling functions 2014-05-13 20:17:54 +04:00
qemu_conf.c migration: add support for migrateURI configuration 2014-05-20 13:13:29 +02:00
qemu_conf.h migration: add support for migrateURI configuration 2014-05-20 13:13:29 +02:00
qemu_domain.c qemu: Avoid leak in qemuDomainCheckRemoveOptionalDisk 2014-05-15 14:45:26 +02:00
qemu_domain.h qemu: Make qemuDomainObjBeginNestedJob static 2014-05-14 13:26:59 +02:00
qemu_driver.c storage: Add NONE protocol type for network disks 2014-05-23 10:08:35 +02:00
qemu_driver.h Change file names in comments to match the files they are in 2014-03-10 14:26:04 +01:00
qemu_hostdev.c drivers: use virDirRead API 2014-04-28 17:52:45 -06:00
qemu_hostdev.h Capitalize USB, PCI and SCSI in hostdev methods 2014-03-12 16:20:01 +00:00
qemu_hotplug.c Return error when updating cdrom device 2014-05-19 18:40:02 +02:00
qemu_hotplug.h qemu: hotplug: Mark 2 private functions as static 2013-12-05 15:34:54 -05:00
qemu_hotplugpriv.h qemu: Let tests override waiting time for device unplug 2013-08-26 16:09:55 +02:00
qemu_migration.c qemu: Properly abort migration to a file 2014-05-23 09:05:53 +02:00
qemu_migration.h libvirt support to force convergence of live guest migration 2014-03-21 14:17:15 +01:00
qemu_monitor_json.c Don't log an internal error when the guest hasn't updated balloon stats 2014-05-22 14:41:10 +02:00
qemu_monitor_json.h qemu: add support for virDomainCoreDumpWithFormat API 2014-03-24 14:14:14 -06:00
qemu_monitor_text.c qemu: specify domain in host-side PCI addresses when needed/supported 2014-05-06 14:34:56 +03:00
qemu_monitor_text.h qemu: Use bool instead of int in qemuMonitorSetCPU APIs 2013-06-07 15:57:03 +02:00
qemu_monitor.c qemu: Avoid overflow when setting migration speed 2014-04-14 13:42:48 +02:00
qemu_monitor.h qemu: add support for virDomainCoreDumpWithFormat API 2014-03-24 14:14:14 -06:00
qemu_process.c qemu: fix RTC_CHANGE event for <clock offset='variable' basis='utc'/> 2014-05-26 13:58:09 +03:00
qemu_process.h util: use typedefs for enums in "src/util/" directory 2014-05-05 14:30:01 -06:00
qemu_processpriv.h qemu: Export qemuProcessHandleDeviceDeleted for tests 2013-08-26 16:09:55 +02:00
qemu.conf migration: add support for migrateURI configuration 2014-05-20 13:13:29 +02:00
test_libvirtd_qemu.aug.in migration: add support for migrateURI configuration 2014-05-20 13:13:29 +02:00
THREADS.txt Remove qemuDriverLock from almost everywhere 2013-02-13 11:10:30 +00:00