mirror of https://gitee.com/openkylin/libvirt.git
Allow configurable timezones with QEMU
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
This commit is contained in:
parent
e4d7433ef0
commit
74042b8fba
|
@ -3071,6 +3071,7 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
|
|||
break;
|
||||
|
||||
case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
|
||||
case VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE:
|
||||
virBufferAddLit(&buf, "base=localtime");
|
||||
break;
|
||||
|
||||
|
@ -3550,6 +3551,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
|||
} else {
|
||||
switch (def->clock.offset) {
|
||||
case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
|
||||
case VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE:
|
||||
ADD_ARG_LIT("-localtime");
|
||||
break;
|
||||
|
||||
|
@ -3564,6 +3566,10 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
|||
goto error;
|
||||
}
|
||||
}
|
||||
if (def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE &&
|
||||
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)
|
||||
|
|
|
@ -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
|
|
@ -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='timezone' 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>
|
|
@ -230,6 +230,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);
|
||||
|
|
Loading…
Reference in New Issue