Newer versions of XenD have the (localtime 1) bit of the SEXPR
moved outside the (image ...) bit, and made available for both PV
and HVM guests. This patch updates our code to cope with this. For
compatability we also still put the (localtime 1) bit inside the
HVM (image ...) section too - its harmless on new XenD, and stops
us breaking old deployments. Finally, this also updates the XM
driver to accept localtime=1 for PV guests.
Daniel
diff -r 00b8aaa2555b src/xend_internal.c
--- a/src/xend_internal.c Tue Mar 31 12:02:49 2009 +0100
+++ b/src/xend_internal.c Tue Mar 31 12:26:01 2009 +0100
@@ -2423,10 +2423,15 @@ xenDaemonParseSxpr(virConnectPtr conn,
if (sexpr_int(root, "domain/image/hvm/pae"))
def->features |= (1 << VIR_DOMAIN_FEATURE_PAE);
+ /* Old XenD only allows localtime here for HVM */
if (sexpr_int(root, "domain/image/hvm/localtime"))
def->localtime = 1;
}
+ /* Current XenD allows localtime here, for PV and HVM */
+ if (sexpr_int(root, "domain/localtime"))
+ def->localtime = 1;
+
if (sexpr_node_copy(root, hvm ?
"domain/image/hvm/device_model" :
"domain/image/linux/device_model",
@@ -5603,6 +5608,10 @@ xenDaemonFormatSxpr(virConnectPtr conn,
}
virBufferVSprintf(&buf, "(on_crash '%s')", tmp);
+ /* Set localtime here for current XenD (both PV & HVM) */
+ if (def->localtime)
+ virBufferAddLit(&buf, "(localtime 1)");
+
if (!def->os.bootloader) {
if (STREQ(def->os.type, "hvm"))
hvm = 1;
@@ -5718,6 +5727,7 @@ xenDaemonFormatSxpr(virConnectPtr conn,
virBufferAddLit(&buf, "(serial none)");
}
+ /* Set localtime here to keep old XenD happy for HVM */
if (def->localtime)
virBufferAddLit(&buf, "(localtime 1)");
diff -r 00b8aaa2555b src/xm_internal.c
--- a/src/xm_internal.c Tue Mar 31 12:02:49 2009 +0100
+++ b/src/xm_internal.c Tue Mar 31 12:26:01 2009 +0100
@@ -819,10 +819,10 @@ xenXMDomainConfigParse(virConnectPtr con
goto cleanup;
else if (val)
def->features |= (1 << VIR_DOMAIN_FEATURE_APIC);
+ }
+ if (xenXMConfigGetBool(conn, conf, "localtime", &def->localtime, 0)
< 0)
+ goto cleanup;
- if (xenXMConfigGetBool(conn, conf, "localtime", &def->localtime,
0) < 0)
- goto cleanup;
- }
if (xenXMConfigCopyStringOpt(conn, conf, "device_model",
&def->emulator) < 0)
goto cleanup;
diff -r 00b8aaa2555b tests/sexpr2xmldata/sexpr2xml-pv-localtime.sexpr
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.sexpr Tue Mar 31 12:26:01 2009 +0100
@@ -0,0 +1,2 @@
+(domain (domid 6)(name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid
'596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot
'destroy')(on_crash 'destroy')(localtime 1)(image (linux (kernel
'/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk
'/var/lib/xen/initrd.img.0u-Vhq')(args '
method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test...
')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode
'w'))))
+
diff -r 00b8aaa2555b tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml Tue Mar 31 12:26:01 2009 +0100
@@ -0,0 +1,27 @@
+<domain type='xen' id='6'>
+ <name>pvtest</name>
+ <uuid>596a5d21-71f4-8fb2-e068-e2386a5c413e</uuid>
+ <memory>430080</memory>
+ <currentMemory>430080</currentMemory>
+ <vcpu>2</vcpu>
+ <os>
+ <type>linux</type>
+ <kernel>/var/lib/xen/vmlinuz.2Dn2YT</kernel>
+ <initrd>/var/lib/xen/initrd.img.0u-Vhq</initrd>
+ <cmdline>
method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test...
</cmdline>
+ </os>
+ <clock offset='localtime'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='file'/>
+ <source file='/root/some.img'/>
+ <target dev='xvda' bus='xen'/>
+ </disk>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ </devices>
+</domain>
diff -r 00b8aaa2555b tests/sexpr2xmltest.c
--- a/tests/sexpr2xmltest.c Tue Mar 31 12:02:49 2009 +0100
+++ b/tests/sexpr2xmltest.c Tue Mar 31 12:26:01 2009 +0100
@@ -145,6 +145,7 @@ mymain(int argc, char **argv)
DO_TEST("bridge-ipaddr", "bridge-ipaddr", 3);
DO_TEST("no-source-cdrom", "no-source-cdrom", 2);
DO_TEST("pci-devs", "pci-devs", 2);
+ DO_TEST("pv-localtime", "pv-localtime", 2);
DO_TEST("fv-utc", "fv-utc", 1);
DO_TEST("fv-localtime", "fv-localtime", 1);
diff -r 00b8aaa2555b tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr
--- a/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr Tue Mar 31 12:02:49 2009 +0100
+++ b/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr Tue Mar 31 12:26:01 2009 +0100
@@ -1,1 +1,1 @@
-(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid
'b5d70dd2-75cd-aca5-1776-9660b059d8bc')(on_poweroff 'destroy')(on_reboot
'restart')(on_crash 'restart')(image (hvm (kernel
'/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom
'/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial none)(localtime
1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev
'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif
(mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script
'vif-bridge')(type ioemu))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid
'b5d70dd2-75cd-aca5-1776-9660b059d8bc')(on_poweroff 'destroy')(on_reboot
'restart')(on_crash 'restart')(localtime 1)(image (hvm (kernel
'/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom
'/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial none)(localtime
1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev
'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif
(mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script
'vif-bridge')(type ioemu))))
\ No newline at end of file
diff -r 00b8aaa2555b tests/xml2sexprdata/xml2sexpr-pv-localtime.sexpr
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/xml2sexprdata/xml2sexpr-pv-localtime.sexpr Tue Mar 31 12:26:01 2009 +0100
@@ -0,0 +1,1 @@
+(vm (name 'rhel5')(memory 175)(maxmem 385)(vcpus 1)(uuid
'4f77abd2-3019-58e8-3bab-6fbf2118f880')(bootloader
'/usr/bin/pygrub')(on_poweroff 'destroy')(on_reboot
'restart')(on_crash 'restart')(localtime 1)(device (tap (dev
'xvda:disk')(uname 'tap:aio:/xen/rhel5.img')(mode 'w')))(device
(vif (mac '00:16:3e:1d:06:15')(bridge 'xenbr0')(script
'vif-bridge'))))
\ No newline at end of file
diff -r 00b8aaa2555b tests/xml2sexprdata/xml2sexpr-pv-localtime.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/xml2sexprdata/xml2sexpr-pv-localtime.xml Tue Mar 31 12:26:01 2009 +0100
@@ -0,0 +1,25 @@
+<domain type='xen' id='5'>
+ <name>rhel5</name>
+ <uuid>4f77abd2301958e83bab6fbf2118f880</uuid>
+ <bootloader>/usr/bin/pygrub</bootloader>
+ <memory>394240</memory>
+ <currentMemory>179200</currentMemory>
+ <vcpu>1</vcpu>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <clock offset='localtime'/>
+ <devices>
+ <interface type='bridge'>
+ <source bridge='xenbr0'/>
+ <mac address='00:16:3e:1d:06:15'/>
+ <script path='vif-bridge'/>
+ </interface>
+ <disk type='file' device='disk'>
+ <driver name='tap' type='aio'/>
+ <source file='/xen/rhel5.img'/>
+ <target dev='xvda:disk'/>
+ </disk>
+ <graphics type='vnc' port='5905'/>
+ </devices>
+</domain>
diff -r 00b8aaa2555b tests/xml2sexprtest.c
--- a/tests/xml2sexprtest.c Tue Mar 31 12:02:49 2009 +0100
+++ b/tests/xml2sexprtest.c Tue Mar 31 12:26:01 2009 +0100
@@ -130,6 +130,7 @@ mymain(int argc, char **argv)
DO_TEST("bridge-ipaddr", "bridge-ipaddr", "pvtest",
2);
DO_TEST("no-source-cdrom", "no-source-cdrom", "test",
2);
DO_TEST("pci-devs", "pci-devs", "pvtest", 2);
+ DO_TEST("pv-localtime", "pv-localtime", "pvtest", 1);
DO_TEST("fv-utc", "fv-utc", "fvtest", 1);
DO_TEST("fv-localtime", "fv-localtime", "fvtest", 1);
Daniel
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://ovirt.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|