[libvirt] [PATCH] Solaris PV is localtime. Allow this setting through the conversions

# HG changeset patch # User john.levon@sun.com # Date 1233198416 28800 # Node ID 76d670ab6ea5476be96441ea88af94644c985201 # Parent f0247b9f4da199c01412d5bd0f9d7d888cbb84de Solaris PV is localtime. Allow this setting through the conversions. Signed-off-by: John Levon <john.levon@sun.com> diff --git a/src/xend_internal.c b/src/xend_internal.c --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -2272,10 +2272,12 @@ xenDaemonParseSxpr(virConnectPtr conn, def->features |= (1 << VIR_DOMAIN_FEATURE_APIC); if (sexpr_int(root, "domain/image/hvm/pae")) def->features |= (1 << VIR_DOMAIN_FEATURE_PAE); - - if (sexpr_int(root, "domain/image/hvm/localtime")) + } + + if (sexpr_int(root, "domain/localtime") || + sexpr_int(root, "domain/image/hvm/localtime") || + sexpr_int(root, "domain/image/linux/localtime")) def->localtime = 1; - } if (sexpr_node_copy(root, hvm ? "domain/image/hvm/device_model" : @@ -5338,6 +5340,14 @@ xenDaemonFormatSxpr(virConnectPtr conn, } virBufferVSprintf(&buf, "(on_crash '%s')", tmp); + /* + * xend puts localtime in image/{hvm,linux}/, but is clearly + * bootloader independent. As a simple workaround, we define it + * here - xend happily picks it up from here. + */ + if (def->localtime) + virBufferAddLit(&buf, "(localtime 1)"); + if (!def->os.bootloader) { if (STREQ(def->os.type, "hvm")) hvm = 1; @@ -5453,9 +5463,6 @@ xenDaemonFormatSxpr(virConnectPtr conn, virBufferAddLit(&buf, "(serial none)"); } - if (def->localtime) - virBufferAddLit(&buf, "(localtime 1)"); - if (def->sounds) { virBufferAddLit(&buf, "(soundhw '"); if (xenDaemonFormatSxprSound(conn, def, &buf) < 0) diff --git a/src/xm_internal.c b/src/xm_internal.c --- a/src/xm_internal.c +++ b/src/xm_internal.c @@ -818,10 +818,11 @@ 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; @@ -1972,6 +1973,9 @@ virConfPtr xenXMDomainConfigFormat(virCo if (xenXMConfigSetInt(conf, "vcpus", def->vcpus) < 0) goto no_memory; + if (def->localtime && xenXMConfigSetInt(conf, "localtime", 1) < 0) + goto no_memory; + if (def->cpumask && !(cpus = virDomainCpuSetFormat(conn, def->cpumask, def->cpumasklen)) < 0) goto cleanup; @@ -2034,9 +2038,6 @@ virConfPtr xenXMDomainConfigFormat(virCo (1 << VIR_DOMAIN_FEATURE_APIC)) ? 1 : 0) < 0) goto no_memory; - - if (xenXMConfigSetInt(conf, "localtime", def->localtime ? 1 : 0) < 0) - goto no_memory; if (priv->xendConfigVersion == 1) { for (i = 0 ; i < def->ndisks ; i++) { diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-localtime2.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-localtime2.sexpr new file mode 100644 --- /dev/null +++ b/tests/sexpr2xmldata/sexpr2xml-fv-localtime2.sexpr @@ -0,0 +1,1 @@ +(domain (domid 3)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(localtime 1)(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(cdrom '/root/boot.iso')(acpi 1)(vnc 1)(keymap ja)))(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)))) diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-localtime2.xml b/tests/sexpr2xmldata/sexpr2xml-fv-localtime2.xml new file mode 100644 --- /dev/null +++ b/tests/sexpr2xmldata/sexpr2xml-fv-localtime2.xml @@ -0,0 +1,41 @@ +<domain type='xen' id='3'> + <name>fvtest</name> + <uuid>b5d70dd2-75cd-aca5-1776-9660b059d8bc</uuid> + <memory>409600</memory> + <currentMemory>409600</currentMemory> + <vcpu>1</vcpu> + <os> + <type>hvm</type> + <loader>/usr/lib/xen/boot/hvmloader</loader> + <boot dev='hd'/> + </os> + <features> + <acpi/> + </features> + <clock offset='localtime'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/lib64/xen/bin/qemu-dm</emulator> + <disk type='file' device='disk'> + <driver name='file'/> + <source file='/root/foo.img'/> + <target dev='hda' bus='ide'/> + </disk> + <disk type='file' device='cdrom'> + <driver name='file'/> + <source file='/root/boot.iso'/> + <target dev='hdc' bus='ide'/> + <readonly/> + </disk> + <interface type='bridge'> + <mac address='00:16:3e:1b:b1:47'/> + <source bridge='xenbr0'/> + <script path='vif-bridge'/> + <target dev='vif3.0'/> + </interface> + <input type='mouse' bus='ps2'/> + <graphics type='vnc' port='5903' autoport='no' keymap='ja'/> + </devices> +</domain> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-localtime.sexpr b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.sexpr new file mode 100644 --- /dev/null +++ b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.sexpr @@ -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/5.91/x86_... ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w')))) + diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml new file mode 100644 --- /dev/null +++ b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml @@ -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/5.91/x86_... </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 --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c --- a/tests/sexpr2xmltest.c +++ b/tests/sexpr2xmltest.c @@ -129,6 +129,7 @@ mymain(int argc, char **argv) DO_TEST("pv-vfb-new-vncdisplay", "pv-vfb-new-vncdisplay", 3); DO_TEST("fv-autoport", "fv-autoport", 3); DO_TEST("pv-bootloader", "pv-bootloader", 1); + DO_TEST("pv-localtime", "pv-localtime", 1); DO_TEST("disk-file", "disk-file", 2); DO_TEST("disk-block", "disk-block", 2); @@ -145,6 +146,7 @@ mymain(int argc, char **argv) DO_TEST("fv-utc", "fv-utc", 1); DO_TEST("fv-localtime", "fv-localtime", 1); + DO_TEST("fv-localtime2", "fv-localtime2", 1); DO_TEST("fv-usbmouse", "fv-usbmouse", 1); DO_TEST("fv-usbtablet", "fv-usbtablet", 1); DO_TEST("fv-kernel", "fv-kernel", 1); diff --git a/tests/xmconfigdata/test-escape-paths.cfg b/tests/xmconfigdata/test-escape-paths.cfg --- a/tests/xmconfigdata/test-escape-paths.cfg +++ b/tests/xmconfigdata/test-escape-paths.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-localtime.cfg b/tests/xmconfigdata/test-fullvirt-localtime.cfg --- a/tests/xmconfigdata/test-fullvirt-localtime.cfg +++ b/tests/xmconfigdata/test-fullvirt-localtime.cfg @@ -3,13 +3,13 @@ maxmem = 579 maxmem = 579 memory = 394 vcpus = 1 +localtime = 1 builder = "hvm" kernel = "/usr/lib/xen/boot/hvmloader" boot = "d" pae = 1 acpi = 1 apic = 1 -localtime = 1 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg b/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg --- a/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg +++ b/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg b/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg --- a/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg +++ b/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 cdrom = "/root/boot.iso" on_poweroff = "destroy" on_reboot = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg b/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg --- a/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg +++ b/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-file.cfg b/tests/xmconfigdata/test-fullvirt-serial-file.cfg --- a/tests/xmconfigdata/test-fullvirt-serial-file.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-file.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-null.cfg b/tests/xmconfigdata/test-fullvirt-serial-null.cfg --- a/tests/xmconfigdata/test-fullvirt-serial-null.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-null.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg b/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg --- a/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-pty.cfg b/tests/xmconfigdata/test-fullvirt-serial-pty.cfg --- a/tests/xmconfigdata/test-fullvirt-serial-pty.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-pty.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg b/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg --- a/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg --- a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg --- a/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-udp.cfg b/tests/xmconfigdata/test-fullvirt-serial-udp.cfg --- a/tests/xmconfigdata/test-fullvirt-serial-udp.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-udp.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-serial-unix.cfg b/tests/xmconfigdata/test-fullvirt-serial-unix.cfg --- a/tests/xmconfigdata/test-fullvirt-serial-unix.cfg +++ b/tests/xmconfigdata/test-fullvirt-serial-unix.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-sound.cfg b/tests/xmconfigdata/test-fullvirt-sound.cfg --- a/tests/xmconfigdata/test-fullvirt-sound.cfg +++ b/tests/xmconfigdata/test-fullvirt-sound.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-usbmouse.cfg b/tests/xmconfigdata/test-fullvirt-usbmouse.cfg --- a/tests/xmconfigdata/test-fullvirt-usbmouse.cfg +++ b/tests/xmconfigdata/test-fullvirt-usbmouse.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-usbtablet.cfg b/tests/xmconfigdata/test-fullvirt-usbtablet.cfg --- a/tests/xmconfigdata/test-fullvirt-usbtablet.cfg +++ b/tests/xmconfigdata/test-fullvirt-usbtablet.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-fullvirt-utc.cfg b/tests/xmconfigdata/test-fullvirt-utc.cfg --- a/tests/xmconfigdata/test-fullvirt-utc.cfg +++ b/tests/xmconfigdata/test-fullvirt-utc.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "restart" on_crash = "restart" diff --git a/tests/xmconfigdata/test-no-source-cdrom.cfg b/tests/xmconfigdata/test-no-source-cdrom.cfg --- a/tests/xmconfigdata/test-no-source-cdrom.cfg +++ b/tests/xmconfigdata/test-no-source-cdrom.cfg @@ -9,7 +9,6 @@ pae = 1 pae = 1 acpi = 1 apic = 1 -localtime = 0 on_poweroff = "destroy" on_reboot = "destroy" on_crash = "destroy" diff --git a/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr --- a/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr +++ b/tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr @@ -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)(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 --git a/tests/xml2sexprdata/xml2sexpr-pv-localtime.sexpr b/tests/xml2sexprdata/xml2sexpr-pv-localtime.sexpr new file mode 100644 --- /dev/null +++ b/tests/xml2sexprdata/xml2sexpr-pv-localtime.sexpr @@ -0,0 +1,1 @@ +(vm (name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d21-71f4-8fb2-e068-e2386a5c413e')(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/5.91/x86_... ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w')))) \ No newline at end of file diff --git a/tests/xml2sexprdata/xml2sexpr-pv-localtime.xml b/tests/xml2sexprdata/xml2sexpr-pv-localtime.xml new file mode 100644 --- /dev/null +++ b/tests/xml2sexprdata/xml2sexpr-pv-localtime.xml @@ -0,0 +1,24 @@ +<domain type='xen' id='15'> + <name>pvtest</name> + <uuid>596a5d2171f48fb2e068e2386a5c413e</uuid> + <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/5.91/x86_... </cmdline> + </os> + <memory>430080</memory> + <vcpu>2</vcpu> + <clock offset='localtime'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>destroy</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='file' device='disk'> + <source file='/root/some.img'/> + <target dev='xvda'/> + </disk> + <console tty='/dev/pts/4'/> + </devices> +</domain> + diff --git a/tests/xml2sexprdata/xml2sexpr-pv-utc.sexpr b/tests/xml2sexprdata/xml2sexpr-pv-utc.sexpr new file mode 100644 --- /dev/null +++ b/tests/xml2sexprdata/xml2sexpr-pv-utc.sexpr @@ -0,0 +1,1 @@ +(vm (name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d21-71f4-8fb2-e068-e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(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/5.91/x86_... ')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w')))) \ No newline at end of file diff --git a/tests/xml2sexprdata/xml2sexpr-pv-utc.xml b/tests/xml2sexprdata/xml2sexpr-pv-utc.xml new file mode 100644 --- /dev/null +++ b/tests/xml2sexprdata/xml2sexpr-pv-utc.xml @@ -0,0 +1,24 @@ +<domain type='xen' id='15'> + <name>pvtest</name> + <uuid>596a5d2171f48fb2e068e2386a5c413e</uuid> + <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/5.91/x86_... </cmdline> + </os> + <memory>430080</memory> + <vcpu>2</vcpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>destroy</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='file' device='disk'> + <source file='/root/some.img'/> + <target dev='xvda'/> + </disk> + <console tty='/dev/pts/4'/> + </devices> +</domain> + diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -112,6 +112,8 @@ mymain(int argc, char **argv) DO_TEST("pv-vfb-new", "pv-vfb-new", "pvtest", 3); DO_TEST("pv-vfb-new-auto", "pv-vfb-new-auto", "pvtest", 3); DO_TEST("pv-bootloader", "pv-bootloader", "pvtest", 1); + DO_TEST("pv-localtime", "pv-localtime", "pvtest", 1); + DO_TEST("pv-utc", "pv-utc", "pvtest", 1); DO_TEST("disk-file", "disk-file", "pvtest", 2); DO_TEST("disk-block", "disk-block", "pvtest", 2);

On Wed, Jan 28, 2009 at 07:09:19PM -0800, john.levon@sun.com wrote:
# HG changeset patch # User john.levon@sun.com # Date 1233198416 28800 # Node ID 76d670ab6ea5476be96441ea88af94644c985201 # Parent f0247b9f4da199c01412d5bd0f9d7d888cbb84de Solaris PV is localtime. Allow this setting through the conversions.
Signed-off-by: John Levon <john.levon@sun.com>
diff --git a/src/xend_internal.c b/src/xend_internal.c --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -2272,10 +2272,12 @@ xenDaemonParseSxpr(virConnectPtr conn, def->features |= (1 << VIR_DOMAIN_FEATURE_APIC); if (sexpr_int(root, "domain/image/hvm/pae")) def->features |= (1 << VIR_DOMAIN_FEATURE_PAE); - - if (sexpr_int(root, "domain/image/hvm/localtime")) + } + + if (sexpr_int(root, "domain/localtime") || + sexpr_int(root, "domain/image/hvm/localtime") || + sexpr_int(root, "domain/image/linux/localtime")) def->localtime = 1; - }
if (sexpr_node_copy(root, hvm ? "domain/image/hvm/device_model" : @@ -5338,6 +5340,14 @@ xenDaemonFormatSxpr(virConnectPtr conn, } virBufferVSprintf(&buf, "(on_crash '%s')", tmp);
+ /* + * xend puts localtime in image/{hvm,linux}/, but is clearly + * bootloader independent. As a simple workaround, we define it + * here - xend happily picks it up from here. + */ + if (def->localtime) + virBufferAddLit(&buf, "(localtime 1)"); +
Hmm, current XenD may not mind having 'localtime' here, but I'm worried older XenD may not be so forgiving. Will have to check older source.
if (!def->os.bootloader) { if (STREQ(def->os.type, "hvm")) hvm = 1; @@ -5453,9 +5463,6 @@ xenDaemonFormatSxpr(virConnectPtr conn, virBufferAddLit(&buf, "(serial none)"); }
- if (def->localtime) - virBufferAddLit(&buf, "(localtime 1)"); - if (def->sounds) { virBufferAddLit(&buf, "(soundhw '"); if (xenDaemonFormatSxprSound(conn, def, &buf) < 0) diff --git a/src/xm_internal.c b/src/xm_internal.c --- a/src/xm_internal.c +++ b/src/xm_internal.c @@ -818,10 +818,11 @@ 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;
@@ -1972,6 +1973,9 @@ virConfPtr xenXMDomainConfigFormat(virCo if (xenXMConfigSetInt(conf, "vcpus", def->vcpus) < 0) goto no_memory;
+ if (def->localtime && xenXMConfigSetInt(conf, "localtime", 1) < 0) + goto no_memory;
Existing code unconditionally sets localtime=0 and localtime=1, but this only sets localtime=1, relying on XM defaults for localtime=0. I prefer not to rely on defaults when writing the config back out to disk because those have a habit of being broken over time. Unconditionally setting it avoids the need to change all those test case config files.
+ if (def->cpumask && !(cpus = virDomainCpuSetFormat(conn, def->cpumask, def->cpumasklen)) < 0) goto cleanup; @@ -2034,9 +2038,6 @@ virConfPtr xenXMDomainConfigFormat(virCo (1 << VIR_DOMAIN_FEATURE_APIC)) ? 1 : 0) < 0) goto no_memory;
- - if (xenXMConfigSetInt(conf, "localtime", def->localtime ? 1 : 0) < 0) - goto no_memory;
if (priv->xendConfigVersion == 1) { for (i = 0 ; i < def->ndisks ; i++) {
Regards, 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 :|

On Thu, Jan 29, 2009 at 11:33:10AM +0000, Daniel P. Berrange wrote:
+ if (def->localtime && xenXMConfigSetInt(conf, "localtime", 1) < 0) + goto no_memory;
Existing code unconditionally sets localtime=0 and localtime=1, but this only sets localtime=1, relying on XM defaults for localtime=0. I prefer not to rely on defaults when writing the config back out to disk because those have a habit of being broken over time. Unconditionally setting it avoids the need to change all those test case config files.
I was attempting to make it work consistently in all cases, and the existing sexpr code doesn't write '(localtime 0)'. What would you prefer? regards john

On Thu, Jan 29, 2009 at 11:33:10AM +0000, Daniel P. Berrange wrote:
Hmm, current XenD may not mind having 'localtime' here, but I'm worried older XenD may not be so forgiving. Will have to check older source.
Any success?
Existing code unconditionally sets localtime=0 and localtime=1, but this only sets localtime=1, relying on XM defaults for localtime=0. I prefer not to rely on defaults when writing the config back out to disk because those have a habit of being broken over time. Unconditionally setting it avoids the need to change all those test case config files.
I'm still hoping for an answer from you here too. I can make it be inconsistent if you like. I'm more concerned about getting the notion of PV localtime into the tree. regards john

On Thu, Feb 05, 2009 at 04:12:39AM +0000, John Levon wrote:
On Thu, Jan 29, 2009 at 11:33:10AM +0000, Daniel P. Berrange wrote:
Hmm, current XenD may not mind having 'localtime' here, but I'm worried older XenD may not be so forgiving. Will have to check older source.
Any success?
After much debugging & code inspection, it looks like we need to explicitly set the 'localtime' config both in the top level of the SEXPR *and* within the image/hvm part of it, in order to cope with all versions of Xen. Some require it in the latter only, some require it in the former only, others are a mix of both depending on PV vs HVM guests, and some are just broken.
Existing code unconditionally sets localtime=0 and localtime=1, but this only sets localtime=1, relying on XM defaults for localtime=0. I prefer not to rely on defaults when writing the config back out to disk because those have a habit of being broken over time. Unconditionally setting it avoids the need to change all those test case config files.
I'm still hoping for an answer from you here too. I can make it be inconsistent if you like. I'm more concerned about getting the notion of PV localtime into the tree.
I'd like to see the config always set an explicit value, so we guarentee that both XM and libvirt pass the same value to XenD. For completeness we should always set it in the SEXPR too, even though we only currently set it when localtime is enabled. Regards, 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 :|
participants (3)
-
Daniel P. Berrange
-
John Levon
-
john.levon@sun.com