Allow an arbitrary timezone with QEMU by setting the $TZ environment
variable when launching QEMU
* src/qemu/qemu_conf.c: Set TZ environment variable if a timezone
is requested
* tests/qemuxml2argvtest.c: Add test case for timezones
* tests/qemuxml2argvdata/qemuxml2argv-clock-france.xml,
tests/qemuxml2argvdata/qemuxml2argv-clock-france.args: Data
for timezone tests
---
src/qemu/qemu_conf.c | 6 ++++-
.../qemuxml2argv-clock-france.args | 1 +
.../qemuxml2argvdata/qemuxml2argv-clock-france.xml | 24 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 2 +
4 files changed, 32 insertions(+), 1 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-clock-france.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-clock-france.xml
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index bf77f3c..d9bea33 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -2903,7 +2903,7 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
time_t now = time(NULL);
struct tm nowbits;
- now += def->adjustment;
+ now += def->data.adjustment;
gmtime_r(&now, &nowbits);
virBufferVSprintf(&buf, "base=%d-%d-%dT%d:%d:%d",
@@ -3381,6 +3381,10 @@ int qemudBuildCommandLine(virConnectPtr conn,
goto error;
}
}
+ if (def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME &&
+ def->clock.data.timezone) {
+ ADD_ENV_PAIR("TZ", def->clock.data.timezone);
+ }
if ((qemuCmdFlags & QEMUD_CMD_FLAG_NO_REBOOT) &&
def->onReboot != VIR_DOMAIN_LIFECYCLE_RESTART)
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-france.args
b/tests/qemuxml2argvdata/qemuxml2argv-clock-france.args
new file mode 100644
index 0000000..3c57397
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-clock-france.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test TZ=Europe/Paris /usr/bin/qemu
-S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -rtc
base=localtime -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none
-parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-france.xml
b/tests/qemuxml2argvdata/qemuxml2argv-clock-france.xml
new file mode 100644
index 0000000..88477b6
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-clock-france.xml
@@ -0,0 +1,24 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='localtime' timezone='Europe/Paris'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0'
unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index dff3e27..23ee5d5 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -222,6 +222,8 @@ mymain(int argc, char **argv)
* Can't be enabled since the absolute timestamp changes every time
DO_TEST("clock-variable", QEMUD_CMD_FLAG_RTC);
*/
+ DO_TEST("clock-france", QEMUD_CMD_FLAG_RTC);
+
DO_TEST("hugepages", QEMUD_CMD_FLAG_MEM_PATH);
DO_TEST("disk-cdrom", 0);
DO_TEST("disk-cdrom-empty", QEMUD_CMD_FLAG_DRIVE);
--
1.6.6