提交 dca1a6b4 编写于 作者: G Guido Günther

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.
上级 c5d2984c
......@@ -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) {
......
(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))))
<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>
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册