Bug 859868
| Summary: | Guest timezone is not the same as what set | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | hongming <honzhang> |
| Component: | libvirt | Assignee: | Osier Yang <jyang> |
| Status: | CLOSED NOTABUG | QA Contact: | Virtualization Bugs <virt-bugs> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 6.4 | CC: | acathrow, berrange, dallan, dyasny, dyuan, hyao, juzhang, mzhan, rwu, yupzhang |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2012-09-29 07:22:44 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: | |||
|
Description
hongming
2012-09-24 08:54:51 UTC
Looking at the command line arguments of QEMU won't tell you the timezone. You need to look at the environment variables instead. (In reply to comment #2) > Looking at the command line arguments of QEMU won't tell you the timezone. > You need to look at the environment variables instead. Right, you should check if the env variable "TZ" is set correctly for "timezone". Add the following info and steps Guest kernel - 2.6.32-279.el6.x86_64 1. Check host timezone # cat /etc/sysconfig/clock ZONE="Asia/Shanghai" 2.Guest timezone is set as follows # virsh dumpxml newrhel6 |grep timezone <clock offset='timezone' timezone='Europe/Paris'> 3.Login guest and check guest timezone # cat /etc/sysconfig/clock ZONE="America/New_York" # hwclock -s # cat /etc/sysconfig/clock ZONE="America/New_York" # hwclock -w # cat /etc/sysconfig/clock ZONE="America/New_York" After confirmed with dev .change the subject. (In reply to comment #4) > Add the following info and steps > > Guest kernel - 2.6.32-279.el6.x86_64 > > > 1. Check host timezone > # cat /etc/sysconfig/clock > ZONE="Asia/Shanghai" > > > 2.Guest timezone is set as follows > # virsh dumpxml newrhel6 |grep timezone > <clock offset='timezone' timezone='Europe/Paris'> > > > 3.Login guest and check guest timezone > # cat /etc/sysconfig/clock > ZONE="America/New_York" > > > # hwclock -s > > > # cat /etc/sysconfig/clock > ZONE="America/New_York" > > > # hwclock -w > > > # cat /etc/sysconfig/clock > ZONE="America/New_York" What's the hardware clock on host? (I.e. output of "hwclock"). I (In reply to comment #6) > (In reply to comment #4) > > Add the following info and steps > > > > Guest kernel - 2.6.32-279.el6.x86_64 > > > > > > 1. Check host timezone > > # cat /etc/sysconfig/clock > > ZONE="Asia/Shanghai" > > > > > > 2.Guest timezone is set as follows > > # virsh dumpxml newrhel6 |grep timezone > > <clock offset='timezone' timezone='Europe/Paris'> > > > > > > 3.Login guest and check guest timezone > > # cat /etc/sysconfig/clock > > ZONE="America/New_York" > > > > > > # hwclock -s > > > > > > # cat /etc/sysconfig/clock > > ZONE="America/New_York" > > > > > > # hwclock -w > > > > > > # cat /etc/sysconfig/clock > > ZONE="America/New_York" > > What's the hardware clock on host? (I.e. output of "hwclock"). I [root@localhost qemu]# hwclock Fri 28 Sep 2012 08:38:24 AM CST -0.809430 seconds More debug datas: LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin TZ=Europe/Paris QEMU_AUDIO_DRV=none /usr/libexec/qemu-kvm -name newrhel6 -S -M rhel6.3.0 -enable-kvm -m 1024 -smp 2,maxcpus=10,sockets=10,cores=1,threads=1 -uuid 8242f7c4-b8e4-1f9c-09ea-17ce0bfebc3b -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/newrhel6.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/libvirt/images/kvm-rhel6.3-x86_64.img,if=none,id=drive-ide0-0-0,format=raw,cache=none -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -netdev tap,fd=23,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:28:65:0f,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -vnc 127.0.0.1:0 -vga cirrus -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 guest# date Fri Sep 28 06:48:53 EDT 2012 guest# hwclock Fri 28 Sep 2012 06:49:45 AM EDT -0.209066 seconds host# hwclock Fri 28 Sep 2012 04:50:04 PM CST -0.754828 seconds host# date Fri Sep 28 16:50:16 CST 2012 (In reply to comment #8) > More debug datas: > > LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin TZ=Europe/Paris > QEMU_AUDIO_DRV=none /usr/libexec/qemu-kvm -name newrhel6 -S -M rhel6.3.0 > -enable-kvm -m 1024 -smp 2,maxcpus=10,sockets=10,cores=1,threads=1 -uuid > 8242f7c4-b8e4-1f9c-09ea-17ce0bfebc3b -nodefconfig -nodefaults -chardev > socket,id=charmonitor,path=/var/lib/libvirt/qemu/newrhel6.monitor,server, > nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime > -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive > file=/var/lib/libvirt/images/kvm-rhel6.3-x86_64.img,if=none,id=drive-ide0-0- > 0,format=raw,cache=none -device > ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 > -netdev tap,fd=23,id=hostnet0 -device > rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:28:65:0f,bus=pci.0,addr=0x3 > -chardev pty,id=charserial0 -device > isa-serial,chardev=charserial0,id=serial0 -vnc 127.0.0.1:0 -vga cirrus > -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device > hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device > virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 > > guest# date > Fri Sep 28 06:48:53 EDT 2012 > > guest# hwclock > Fri 28 Sep 2012 06:49:45 AM EDT -0.209066 seconds > > host# hwclock > Fri 28 Sep 2012 04:50:04 PM CST -0.754828 seconds > > host# date > Fri Sep 28 16:50:16 CST 2012 Hi, Paolo, It's said that you knowns qemu timer well, do you known why it's such different? IIUC, -rtc base=localtime should start the guest clock with current host time. And "ret = localtime(&ti);" will also honor the env variable TZ. So it's strange for me why they are different (ntp service in guest is disabled). Your test scenarios are flawed. The <clock> config in libvirt XML *only* controls what time is stored in the BIOS virtual clock. It has no effect on the actuall OS configuration. So if you set a custom timezone in the XML, you need to manually configure the guest with the matching time, and also tell the guest that its hardware cllock is set to localtime, not UTC To test this you need todo: - On the host # TZ=Europe/Paris date - In the guest # TZ=Europe/Paris hwclock --localtime and they should match - and do match in my testing. So, there are three timezones involved:
- EDT (America/New_York), which is 4 hours before UTC (Greenwhich).
- CST (Asia/Shanghai), which is 8 hours after UTC.
- CEST (Europe/Paris) is (at this time of year) 2 hours after UTC.
The time when the guest was started is 16:50 CST = 08:50 UTC.
Inside QEMU, localtime returns CEST. So the RTC was initialized with 10:50.
Your guest is probably configured for "-rtc base=utc". It interprets 10:50 as UTC and prints a result that is 4 hours less than what is answered.
The reason of the confusion is that the <clock> element should match your guest's configuration. Setting the timezone to Europe/Paris while the guest believes to be in America/New_York is invalid.
However, I won't close it immediately as NOTABUG. Please do the following tests.
- ensure the timezone in the guest to America/New_York. Start the VM with <clock offset="utc">. The following two pairs of commands should give the same output on the guest and the host:
guest host
------------------------------------------------------------
date TZ=America/New_York date
TZ=Asia/Shanghai date date
In other words, "date" output in the guest should be 12 hours before the "date" output in the host. This is correct, because that's the time a hypothetical user from New York would see on his watch.
- open system-config-date and turn off the "System clock uses UTC" checkbox in the Timezone tab. Turn off the VM. Start it again, this time with <clock offset="timezone" timezone="America/New_York">. Repeat the same tests as step 1. They should have the same results.
- open system-config-date and set the timezone to Asia/Shanghai. Leave the checkbox off. Turn off the VM. Start it again, this time with <clock offset="localtime">. The following two pairs of commands should give the same output on the guest and the host:
guest host
------------------------------------------------------------
date date
TZ=America/New_York date TZ=America/New_York date
- open system-config-date and put the checkbox on again. Turn off the VM. Start it again, this time with <clock offset="utc">. Repeat the same test as step 3. They should have the same results.
Perhaps this can be added to the test plan?
(In reply to comment #11) > So, there are three timezones involved: > - EDT (America/New_York), which is 4 hours before UTC (Greenwhich). > - CST (Asia/Shanghai), which is 8 hours after UTC. > - CEST (Europe/Paris) is (at this time of year) 2 hours after UTC. > > The time when the guest was started is 16:50 CST = 08:50 UTC. > > Inside QEMU, localtime returns CEST. So the RTC was initialized with 10:50. > > Your guest is probably configured for "-rtc base=utc". It interprets 10:50 > as UTC and prints a result that is 4 hours less than what is answered. > > The reason of the confusion is that the <clock> element should match your > guest's configuration. Setting the timezone to Europe/Paris while the guest > believes to be in America/New_York is invalid. > > However, I won't close it immediately as NOTABUG. Please do the following > tests. > > - ensure the timezone in the guest to America/New_York. Start the VM with > <clock offset="utc">. The following two pairs of commands should give the > same output on the guest and the host: > > guest host > ------------------------------------------------------------ > date TZ=America/New_York date > TZ=Asia/Shanghai date date > > In other words, "date" output in the guest should be 12 hours before the > "date" output in the host. This is correct, because that's the time a > hypothetical user from New York would see on his watch. > > - open system-config-date and turn off the "System clock uses UTC" checkbox > in the Timezone tab. Turn off the VM. Start it again, this time with > <clock offset="timezone" timezone="America/New_York">. Repeat the same > tests as step 1. They should have the same results. > > - open system-config-date and set the timezone to Asia/Shanghai. Leave the > checkbox off. Turn off the VM. Start it again, this time with <clock > offset="localtime">. The following two pairs of commands should give the > same output on the guest and the host: > > guest host > ------------------------------------------------------------ > date date > TZ=America/New_York date TZ=America/New_York date > > - open system-config-date and put the checkbox on again. Turn off the VM. > Start it again, this time with <clock offset="utc">. Repeat the same test > as step 3. They should have the same results. > > > Perhaps this can be added to the test plan? Thanks, paolo, with explaination from you and Daniel, finally I'm clear. @Hongming, could you do the testing, and add it to the testplan? Do the following test. The results are expected. Have add it to test plan. ================================================================================ The timezone of guest is America/New_York. # virsh start rhel6.3 Domain rhel6.3 started # virsh dumpxml rhel6.3 |grep clock <clock offset='utc'/> guest | host ---------------------------------------------------------------------------- # date |# TZ=America/New_York date Fri Sep 28 22:20:18 EDT 2012 |Fri Sep 28 22:20:29 EDT 2012 ---------------------------------------------------------------------------- # TZ=Asia/Shanghai date |# date Sat Sep 29 10:21:49 CST 2012 |Sat Sep 29 10:22:11 CST 2012 ---------------------------------------------------------------------------- ================================================================================ Open system-config-date and turn off the "System clock uses UTC" checkbox in the Timezone tab # virsh destroy rhel6.3 Domain rhel6.3 destroyed # virsh edit rhel6.3 ( <clock offset="timezone" timezone="America/New_York"> ) Domain rhel6.3 XML configuration edited. # virsh start rhel6.3 Domain rhel6.3 started # virsh dumpxml rhel6.3 |grep clock <clock offset='timezone' timezone='America/New_York'/> guest | host ---------------------------------------------------------------------------- # date |# TZ=America/New_York date Fri Sep 28 22:44:06 EDT 2012 |Fri Sep 28 22:44:49 EDT 2012 ---------------------------------------------------------------------------- # TZ=Asia/Shanghai date |# date Sat Sep 29 10:45:16 CST 2012 |Sat Sep 29 10:45:32 CST 2012 ---------------------------------------------------------------------------- =============================================================================== Open system-config-date and set the timezone to Asia/Shanghai.Leave the "System clock uses UTC" off. # virsh edit rhel6.3 (<clock offset='localtime'/>) Domain rhel6.3 XML configuration edited. # virsh destroy rhel6.3 Domain rhel6.3 destroyed # virsh start rhel6.3 Domain rhel6.3 started # virsh dumpxml rhel6.3 |grep clock <clock offset='localtime'/> guest | host ---------------------------------------------------------------------------- # date |# date Sat Sep 29 11:09:20 CST 2012 |Sat Sep 29 11:09:41 CST 2012 ---------------------------------------------------------------------------- # TZ=America/New_York date |# TZ=America/New_York date Fri Sep 28 23:10:46 EDT 2012 |Fri Sep 28 23:10:10 EDT 2012 ---------------------------------------------------------------------------- ============================================================================== Open system-config-date and put the checkbox on # virsh edit rhel6.3 (<clock offset='utc'/>) Domain rhel6.3 XML configuration edited. # virsh destroy rhel6.3 Domain rhel6.3 destroyed # virsh start rhel6.3 Domain rhel6.3 started # virsh dumpxml rhel6.3 |grep clock <clock offset='utc'/> guest | host ---------------------------------------------------------------------------- # date |# date Sat Sep 29 11:25:55 CST 2012 |Sat Sep 29 11:25:00 CST 2012 ---------------------------------------------------------------------------- # TZ=America/New_York date |# TZ=America/New_York date Fri Sep 28 23:26:53 EDT 2012 |Fri Sep 28 23:27:27 EDT 2012 ---------------------------------------------------------------------------- (In reply to comment #13) > Do the following test. The results are expected. Have add it to test plan. > Close the bug as NOTABUG then. |