Bug 479203 - SEGFAULT during KVM guest creation when machine attribute not defined
SEGFAULT during KVM guest creation when machine attribute not defined
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
x86_64 Linux
low Severity medium
: ---
: ---
Assigned To: Daniel Veillard
Depends On:
  Show dependency treegraph
Reported: 2009-01-07 18:39 EST by aaron.moate
Modified: 2010-03-16 13:17 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2009-03-12 06:54:07 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description aaron.moate 2009-01-07 18:39:24 EST
Description of problem:
A SEGFAULT is raised when starting a 32-bit KVM guest on a host that has KVM installed (but not qemu). 

Version-Release number of selected component (if applicable):
libvirt: LIBVIRT_0_5_1-146-gb035434
linux : v2.6.28-rc7-275-g4e6f2ba
kvm-userspace: kvm-81

How reproducible: Very

Steps to Reproduce:
1.Install kvm-userspace without installing qemu. Run libvirtd.  'virsh -c qemu:///system capabilities' should yield something like this:


    <arch name='x86_64'>
      <domain type='kvm'>
      <acpi default='on' toggle='yes'/>
      <apic default='on' toggle='no'/>

2.Create a definition for a kvm guest (32 bit Windows XP in this case) with a 'type' element of <type arch="i686">hvm</type>.  Example:
<domain type='kvm'>
    <type arch="i686">hvm</type>
    <disk type='file' device='disk'>
      <source file='/mnt/sda3/w2k3-test.qcow2'/>
      <target dev='hda' bus='ide'/>
    <disk type='file' device='cdrom'>
      <target dev='hdb' bus='ide'/>
    <interface type='ethernet'>
      <target dev='tap1'/>
      <model type='e1000'/>
      <script path='/usr/local/bin/qemu-if'/>
    <graphics type='vnc' port='-1'/>
    <input type='tablet' bus='usb'/>
3.run 'virsh -c qemu:///system start john-doe-2'
Actual results:
Libvirtd will exit with a SEGFAULT

Expected results:
Libvirtd should start the defined domain

Additional info:
The actual SEGFAULT is the result of a strdup at qemu_conf.c:777


vm-def->os.machine is NULL.  It was not defined in the xml definition (because I did it by hand), and the arch of the guest did not match the arch of any capabilites in virCapabilitiesDefaultGuestMachine (capabilities.c:465) 
because the guest's arch is i686, so a default value was not given.  qemudCapsInitGuest (qemu_conf.c:206) does not add the arch i686 capability because /usrb/bin/qemu does not exist, and because the host is not an i686.

The SEGFAULT would not happen in any of the following conditions:
1)touch /usr/bin/qemu
2)the arch attribute of the guest had been set to "x86_64"
3)the machine attribute of the guest had been set

I realize the SEGFAULT was created because of user error (The arch of the guest should have been "x86_64"), but it would probably be optimal if a bad configuration file didn't result in a SEGFAULT.
Comment 1 Daniel Berrange 2009-01-29 09:07:01 EST
Patch sent upstream

Comment 2 Daniel Berrange 2009-03-12 06:54:07 EDT
This was included in 0.6.0 release, so it no long crashes

Note You need to log in before you can comment on or make changes to this bug.