tests: exercise a bug that could make virsh and libvirtd segfault

* tests/define-dev-segfault: New file.
* tests/Makefile.am (test_scripts): Add define-dev-segfault.
This commit is contained in:
Jim Meyering 2009-01-16 18:06:33 +00:00
parent 46d4a5e047
commit 735329b824
3 changed files with 83 additions and 0 deletions

View File

@ -1,3 +1,9 @@
Fri Jan 16 18:41:40 +0100 2009 Jim Meyering <meyering@redhat.com>
tests: exercise a bug that could make virsh and libvirtd segfault
* tests/define-dev-segfault: New file.
* tests/Makefile.am (test_scripts): Add define-dev-segfault.
Fri Jan 16 11:48:41 EST 2009 Cole Robinson <crobinso@redhat.com>
* src/domain_conf.c: Fix segfault with console device back compat.

View File

@ -61,6 +61,7 @@ test_scripts += \
test_conf.sh \
cpuset \
daemon-conf \
define-dev-segfault \
int-overflow \
read-bufsiz \
read-non-seekable \

76
tests/define-dev-segfault Executable file
View File

@ -0,0 +1,76 @@
#!/bin/sh
# Exercise a bug whereby defining a valid domain could kill libvirtd.
# The bug can also be exercised with a simple define/dumpxml pair to virsh.
if test "$VERBOSE" = yes; then
set -x
virsh --version
fi
test -z "$srcdir" && srcdir=$(pwd)
test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
. "$srcdir/test-lib.sh"
fail=0
# Domain definition from Cole Robinson.
cat <<\EOF > D.xml || fail=1
<domain type='kvm'>
<name>D</name>
<uuid>aaa3ae22-fed2-bfbd-ac02-3bea3bcfad82</uuid>
<memory>262144</memory>
<currentMemory>262144</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='cdrom'/>
</os>
<features>
<acpi/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<serial type='pty'>
<target port='0'/>
</serial>
<serial type='pty'>
<target port='1'/>
</serial>
<serial type='pty'>
<target port='2'/>
</serial>
<parallel type='pty'>
<target port='0'/>
</parallel>
<parallel type='pty'>
<target port='1'/>
</parallel>
<parallel type='pty'>
<target port='2'/>
</parallel>
<console type='pty'>
<target port='0'/>
</console>
<sound model='pcspk'/>
<sound model='es1370'/>
</devices>
</domain>
EOF
url=test:///default
virsh --connect "$url" 'define D.xml; dumpxml D' > out 2>&1 || fail=1
cat > exp <<EOF || fail=1
Domain D defined from D.xml
$(cat D.xml)
EOF
compare exp out || fail=1
exit $fail