Bug 1219191

Summary: Regression: libvirt-1.2.15-1.el7 adds -cpu qemu32 to command line when no <cpu> or os/@arch is specified
Product: Red Hat Enterprise Linux 7 Reporter: Richard W.M. Jones <rjones>
Component: libvirtAssignee: Cole Robinson <crobinso>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: crobinso, dyuan, jdenemar, knoel, lhuang, rbalakri
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.2.15-2.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:30:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 910269, 1194593    

Description Richard W.M. Jones 2015-05-06 19:27:43 UTC
Description of problem:

The libguestfs tests in RHEL 7.2 now fail, apparently due to the
update to libvirt-1.2.15-1.el7.

When creating a domain using the following XML, on an x86-64 host:

<domain type="qemu" xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0">
  <name>guestfs-iitlmm568jzhroil</name>
  <memory unit="MiB">500</memory>
  <currentMemory unit="MiB">500</currentMemory>
  <vcpu>1</vcpu>
  <clock offset="utc">
    <timer name="rtc" tickpolicy="catchup"/>
    <timer name="pit" tickpolicy="delay"/>
    <timer name="hpet" present="no"/>
  </clock>
  <os>
    <type>hvm</type>
    <kernel>/builddir/build/BUILD/libguestfs-1.28.1/tmp/.guestfs-498/appliance.d/kernel</kernel>
    <initrd>/builddir/build/BUILD/libguestfs-1.28.1/tmp/.guestfs-498/appliance.d/initrd</initrd>
    <cmdline>panic=1 console=ttyS0 udevtimeout=6000 udev.event-timeout=6000 no_timer_check acpi=off printk.time=1 cgroup_disable=memory root=/dev/sdb selinux=0 guestfs_verbose=1 TERM=vt100</cmdline>
    <bios useserial="yes"/>
  </os>
  <on_reboot>destroy</on_reboot>
  <devices>
    <controller type="scsi" index="0" model="virtio-scsi"/>
    <disk device="disk" type="file">
      <source file="/builddir/build/BUILD/libguestfs-1.28.1/tmp/libguestfsgXYdLc/scratch.1"/>
      <target dev="sda" bus="scsi"/>
      <driver name="qemu" type="raw" cache="unsafe"/>
      <address type="drive" controller="0" bus="0" target="0" unit="0"/>
    </disk>
    <disk type="file" device="disk">
      <source file="/builddir/build/BUILD/libguestfs-1.28.1/tmp/libguestfsgXYdLc/overlay2"/>
      <target dev="sdb" bus="scsi"/>
      <driver name="qemu" type="qcow2" cache="unsafe"/>
      <address type="drive" controller="0" bus="0" target="1" unit="0"/>
      <shareable/>
    </disk>
    <serial type="unix">
      <source mode="connect" path="/builddir/build/BUILD/libguestfs-1.28.1/tmp/libguestfsgXYdLc/console.sock"/>
      <target port="0"/>
    </serial>
    <channel type="unix">
      <source mode="connect" path="/builddir/build/BUILD/libguestfs-1.28.1/tmp/libguestfsgXYdLc/guestfsd.sock"/>
      <target type="virtio" name="org.libguestfs.channel.0"/>
    </channel>
  </devices>
  <qemu:commandline>
    <qemu:env name="TMPDIR" value="/builddir/build/BUILD/libguestfs-1.28.1/tmp"/>
  </qemu:commandline>
</domain>

libvirt generates a qemu command line containing an impossible
cpu: -cpu qemu32.  The full command line is:

LC_ALL=C LD_LIBRARY_PATH=/builddir/build/BUILD/libguestfs-1.28.1/ruby/ext/guestfs:/builddir/build/BUILD/libguestfs-1.28.1/src/.libs:/builddir/build/BUILD/libguestfs-1.28.1/java/.libs:/builddir/build/BUILD/libguestfs-1.28.1/gobject/.libs PATH=/builddir/build/BUILD/libguestfs-1.28.1/align:/builddir/build/BUILD/libguestfs-1.28.1/builder:/builddir/build/BUILD/libguestfs-1.28.1/cat:/builddir/build/BUILD/libguestfs-1.28.1/customize:/builddir/build/BUILD/libguestfs-1.28.1/df:/builddir/build/BUILD/libguestfs-1.28.1/diff:/builddir/build/BUILD/libguestfs-1.28.1/edit:/builddir/build/BUILD/libguestfs-1.28.1/erlang:/builddir/build/BUILD/libguestfs-1.28.1/fish:/builddir/build/BUILD/libguestfs-1.28.1/format:/builddir/build/BUILD/libguestfs-1.28.1/fuse:/builddir/build/BUILD/libguestfs-1.28.1/inspector:/builddir/build/BUILD/libguestfs-1.28.1/make-fs:/builddir/build/BUILD/libguestfs-1.28.1/p2v:/builddir/build/BUILD/libguestfs-1.28.1/rescue:/builddir/build/BUILD/libguestfs-1.28.1/resize:/builddir/build/BUILD/libguestfs-1.28.1/sparsify:/builddir/build/BUILD/libguestfs-1.28.1/sysprep:/builddir/build/BUILD/libguestfs-1.28.1/test-tool:/builddir/build/BUILD/libguestfs-1.28.1/tools:/builddir/build/BUILD/libguestfs-1.28.1/v2v:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/builddir/.local/bin:/builddir/bin HOME=/builddir USER=mockbuild LOGNAME=mockbuild TMPDIR=/builddir/build/BUILD/libguestfs-1.28.1/tmp QEMU_AUDIO_DRV=none /usr/libexec/qemu-kvm -name guestfs-iitlmm568jzhroil -S -machine pc-i440fx-rhel7.0.0,accel=tcg,usb=off -cpu qemu32 -m 500 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 7fb7c6e2-aa4e-4d82-a562-3e55d02a3d9d -nographic -no-user-config -nodefaults -device sga -chardev socket,id=charmonitor,path=/builddir/.config/libvirt/qemu/lib/guestfs-iitlmm568jzhroil.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet -no-reboot -no-acpi -boot strict=on -kernel /builddir/build/BUILD/libguestfs-1.28.1/tmp/.guestfs-498/appliance.d/kernel -initrd /builddir/build/BUILD/libguestfs-1.28.1/tmp/.guestfs-498/appliance.d/initrd -append panic=1 console=ttyS0 udevtimeout=6000 udev.event-timeout=6000 no_timer_check acpi=off printk.time=1 cgroup_disable=memory root=/dev/sdb selinux=0 guestfs_verbose=1 TERM=vt100 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4 -drive file=/builddir/build/BUILD/libguestfs-1.28.1/tmp/libguestfsgXYdLc/scratch.1,if=none,id=drive-scsi0-0-0-0,format=raw,cache=unsafe -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 -drive file=/builddir/build/BUILD/libguestfs-1.28.1/tmp/libguestfsgXYdLc/overlay2,if=none,id=drive-scsi0-0-1-0,format=qcow2,cache=unsafe -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=1,lun=0,drive=drive-scsi0-0-1-0,id=scsi0-0-1-0 -chardev socket,id=charserial0,path=/builddir/build/BUILD/libguestfs-1.28.1/tmp/libguestfsgXYdLc/console.sock -device isa-serial,chardev=charserial0,id=serial0 -chardev socket,id=charchannel0,path=/builddir/build/BUILD/libguestfs-1.28.1/tmp/libguestfsgXYdLc/guestfsd.sock -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.libguestfs.channel.0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -msg timestamp=on

Needless to say this doesn't work at all and the kernel
in the domain soon fails with:

  This kernel requires an x86-64 CPU, but only detected an i686 CPU.

Version-Release number of selected component (if applicable):

libvirt 0:1.2.15-1.el7

How reproducible:

100%

Steps to Reproduce:
1. Build libguestfs in RHEL 7.2 from dist-git

Actual results:

The failing build is:
https://brewweb.devel.redhat.com/taskinfo?taskID=9121019

The action happens at the bottom of the build log.

Comment 3 Cole Robinson 2015-05-06 23:00:28 UTC
Sent a patch upstream:

https://www.redhat.com/archives/libvir-list/2015-May/msg00176.html

Comment 4 Richard W.M. Jones 2015-05-07 14:05:42 UTC
*** Bug 1219198 has been marked as a duplicate of this bug. ***

Comment 5 Richard W.M. Jones 2015-05-09 17:02:26 UTC
The upstream commit is:
https://libvirt.org/git/?p=libvirt.git;a=commit;h=8910e063dbafc09695b2100c80213be569abb7ef

Comment 6 Richard W.M. Jones 2015-05-11 11:38:47 UTC
Posted on rhvirt-patches:

http://post-office.corp.redhat.com/archives/rhvirt-patches/2015-May/thread.html#00173

Note this bug blocks all testing of virt-v2v & virt-p2v.

Comment 8 Richard W.M. Jones 2015-05-12 07:36:08 UTC
Reassigning to Cole since he did the fix.  The bug is fixed
and included in libvirt 1.2.15-2 and I have confirmed that it
fixes the libguestfs build, so there is nothing further
for development to do here.

Comment 9 Luyao Huang 2015-07-22 08:42:59 UTC
i can reproduce this issue with libvirt-1.2.15-1.el7.x86_64:

1. prepare a guest which not specified arch:

# lscpu
Architecture:          x86_64
...

# cat /tmp/tmp.xml
<domain type='kvm'>
  <name>rhel7.0-rhel</name>
  <uuid>67c7a123-5415-4136-af62-a2ee098ba6cd</uuid>
  <maxMemory slots='16' unit='KiB'>25600000</maxMemory>
  <memory unit='KiB'>2072576</memory>
  <currentMemory unit='KiB'>2072576</currentMemory>
  <vcpu placement='static'>4</vcpu>
  <iothreads>1</iothreads>
  <iothreadids>
    <iothread id='1'/>
  </iothreadids>
  <cputune>
    <iothreadpin iothread='1' cpuset='1'/>
  </cputune>
  <os>
    <type>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <cpu>
    <numa>
      <cell id='0' cpus='0-1' memory='512000' unit='KiB'/>
      <cell id='1' cpus='2-3' memory='512000' unit='KiB'/>
    </numa>
  </cpu>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/fs/r7_ext4.raw'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </controller>
    <interface type='network'>
      <mac address='52:54:00:af:19:fb'/>
      <source network='default'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target type='isa-serial' port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <channel type='spicevmc'>
      <target type='virtio' name='com.redhat.spice.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/r6.agent'/>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='2'/>
    </channel>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='spice' autoport='yes'/>
    <sound model='ich6'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </sound>
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <redirdev bus='usb' type='pty'>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
    </redirdev>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </memballoon>
    <memory model='dimm'>
      <source>
        <nodemask>0</nodemask>
        <pagesize unit='KiB'>4</pagesize>
      </source>
      <target>
        <size unit='KiB'>524288</size>
        <node>0</node>
      </target>
    </memory>
    <memory model='dimm'>
      <source>
        <nodemask>0</nodemask>
        <pagesize unit='KiB'>4</pagesize>
      </source>
      <target>
        <size unit='KiB'>524288</size>
        <node>0</node>
      </target>
    </memory>
  </devices>
</domain>

# virsh create /tmp/tmp.xml
Domain rhel7.0-rhel created from /tmp/tmp.xml

2. recheck the xml and qemu command line:

# virsh dumpxml rhel7.0-rhel |grep arch
    <type arch='i686' machine='pc-i440fx-rhel7.2.0'>hvm</type>

3. ps aux|grep rhel7.0-rhel
...
-machine pc-i440fx-rhel7.2.0,accel=kvm,usb=off -cpu qemu32 
...

And verify this issue with libvirt-1.2.17-2.el7.x86_64:

1
# virsh create /tmp/tmp.xml
Domain rhel7.0-rhel created from /tmp/tmp.xml

2. check xml
# virsh dumpxml rhel7.0-rhel |grep arch
    <type arch='x86_64' machine='pc-i440fx-rhel7.2.0'>hvm</type>

3. check qemu command line, no qemu32 here:

# ps aux|grep qemu
qemu     10949 33.6  5.6 2738100 402780 ?      Sl   16:40   0:18 /usr/libexec/qemu-kvm -name rhel7.0-rhel -S -machine pc-i440fx-rhel7.2.0,accel=kvm,usb=off -m size=1024000k,slots=16,maxmem=25600000k -realtime mlock=off -smp 4,sockets=4,cores=1,threads=1 -object iothread,id=iothread1

Comment 11 errata-xmlrpc 2015-11-19 06:30:13 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2202.html