xen_xs: Guard against set but empty kernel argument

On xen 4.1 I observed configurations that look like:

(image
    (hvm
        (kernel '')
        (loader '/foo/bar')
))

The kernel element is there but unset. This leads to an empty <kernel/>
element in the XML and even worse makes us skip the boot order parsing
and therefore not emit a <boot device='$dev>'/> element which breaks CD
booting.
This commit is contained in:
Guido Günther 2011-10-10 18:22:44 +02:00
parent c5d2984c42
commit dca1a6b46f
4 changed files with 58 additions and 0 deletions

View File

@ -125,6 +125,12 @@ xenParseSxprOS(const struct sexpr *node,
STREQ(def->os.kernel, def->os.loader)) {
VIR_FREE(def->os.kernel);
}
/* Drop kernel argument that has no value */
if (hvm &&
def->os.kernel && *def->os.kernel == '\0' &&
def->os.loader) {
VIR_FREE(def->os.kernel);
}
if (!def->os.kernel &&
hvm) {

View File

@ -0,0 +1,9 @@
(domain (domid 3)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)\
(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')\
(on_reboot 'restart')(on_crash 'restart')\
(image (hvm (loader /usr/lib/xen/boot/hvmloader)(kernel '')\
(device_model '/usr/lib64/xen/bin/qemu-dm')(boot d)(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))))

View File

@ -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='cdrom'/>
</os>
<features>
<acpi/>
</features>
<clock offset='utc'/>
<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>

View File

@ -180,6 +180,8 @@ mymain(void)
DO_TEST("fv-net-ioemu", "fv-net-ioemu", 1);
DO_TEST("fv-net-netfront", "fv-net-netfront", 1);
DO_TEST("fv-empty-kernel", "fv-empty-kernel", 1);
DO_TEST("boot-grub", "boot-grub", 1);
virCapabilitiesFree(caps);