Bug 479203 - SEGFAULT during KVM guest creation when machine attribute not defined
SEGFAULT during KVM guest creation when machine attribute not defined
Status: CLOSED CURRENTRELEASE
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
unspecified
x86_64 Linux
low Severity medium
: ---
: ---
Assigned To: Daniel Veillard
:
Depends On:
Blocks:
  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:
Environment:
Last Closed: 2009-03-12 06:54:07 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
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:
<capabilities>

  <host>
    <cpu>
      <arch>x86_64</arch>
    </cpu>
  </host>

  <guest>
    <os_type>hvm</os_type>
    <arch name='x86_64'>
      <wordsize>64</wordsize>
      <emulator>/usr/bin/qemu-system-x86_64</emulator>
      <machine>pc</machine>
      <machine>isapc</machine>
      <domain type='kvm'>
        <emulator>/usr/bin/qemu-kvm</emulator>
      </domain>
    </arch>
    <features>
      <acpi default='on' toggle='yes'/>
      <apic default='on' toggle='no'/>
    </features>
  </guest>

</capabilities>
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'>
  <name>john-doe-2</name>
  <uuid>7f155bc9-2799-aafd-a7c7-3ede49b722a0</uuid>
  <memory>524288</memory>
  <currentMemory>524288</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch="i686">hvm</type>
  </os>
  <devices>
    <emulator>/usr/local/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <source file='/mnt/sda3/w2k3-test.qcow2'/>
      <target dev='hda' bus='ide'/>
    </disk>
    <disk type='file' device='cdrom'>
      <target dev='hdb' bus='ide'/>
      <readonly/>
    </disk>
    <interface type='ethernet'>
      <ifname>tap1</ifname>
      <target dev='tap1'/>
      <model type='e1000'/>
      <script path='/usr/local/bin/qemu-if'/>
    </interface>
    <graphics type='vnc' port='-1'/>
    <input type='tablet' bus='usb'/>
  </devices>
</domain>
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

    ADD_ARG_LIT("-M");
    ADD_ARG_LIT(vm->def->os.machine);

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

http://www.redhat.com/archives/libvir-list/2009-January/msg00765.html
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.