Bug 1182448

Summary: cpu features are not formatted in XML for host-model
Product: Red Hat Enterprise Linux 7 Reporter: Song Wang <sowang>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, jdenemar, jmiao, lmiksik, mzhan, rbalakri
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.8-14.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 07:49:10 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:

Description Song Wang 2015-01-15 06:37:45 UTC
Description of problem:
guest has CPU feature such as 'invtsc', but not shown in xml and the feature disappers when starting guest two times.

Version-Release number of selected component (if applicable):
libvirt-1.2.8-12.el7.x86_64
qemu-kvm-rhev-2.1.2-19.el7.x86_64
kernel-3.10.0-221.el7.x86_64



How reproducible:
100%

Steps to Reproduce:
1[root@localhost songwang]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     aa                             shut off

2.add these to xml.
 <cpu mode='host-model'>
    <model fallback='allow'/>
    <feature policy='require' name='invtsc'/>
  </cpu>

3.[root@localhost songwang]# virsh start aa
Domain aa started

4.[root@localhost songwang]# virsh dumpxml aa |grep host-model -A3
  <cpu mode='host-model'>
    <model fallback='allow'/>              <<--can not find 'invtsc'
  </cpu>
  <clock offset='utc'/>

5.[root@localhost songwang]# ps aux |grep qemu
qemu     32341 54.4  2.7 4110776 216948 ?      Sl   13:37   0:08 /usr/libexec/qemu-kvm -name aa -S -machine pc-i440fx-rhel7.1.0,accel=kvm,usb=off -cpu SandyBridge,+invtsc,+erms,+smep,+fsgsbase,+rdrand,+f16c,+osxsave,+pcid,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme -m 1032 -realtime mlock=off -smp 4,sockets=4,cores=1,threads=1 -uuid 23d19d5a-ee01-4a2b-bec9-948fca512c00 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/aa.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot strict=on -device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x4 -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.0,addr=0x3 -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x6.0x7 -drive file=/var/lib/libvirt/images/r7.img,if=none,id=drive-virtio-disk0,format=raw,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x8,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=23,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:5a:a0:8c,bus=pci.0,addr=0x5 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -spice port=5900,addr=127.0.0.1,disable-ticketing,seamless-migration=on -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vgamem_mb=8,bus=pci.0,addr=0x2 -device intel-hda,id=sound0,bus=pci.0,addr=0x7 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x9 -msg timestamp=on

'invtsc' can be found.

6.[root@localhost songwang]# virsh save aa aa.save
error: Failed to save domain aa to aa.save
error: Requested operation is not valid: domain has CPU feature: invtsc          <--It works well

7.[root@localhost songwang]# virsh destroy aa
Domain aa destroyed

8.[root@localhost songwang]# virsh start aa
Domain aa started

9.[root@localhost songwang]# ps aux |grep qemu
qemu       387 54.8  3.1 3957936 246148 ?      Sl   13:40   0:09 /usr/libexec/qemu-kvm -name aa -S -machine pc-i440fx-rhel7.1.0,accel=kvm,usb=off -cpu SandyBridge,+erms,+smep,+fsgsbase,+rdrand,+f16c,+osxsave,+pcid,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme -m 1032 -realtime mlock=off -smp 4,sockets=4,cores=1,threads=1 -uuid 23d19d5a-ee01-4a2b-bec9-948fca512c00 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/aa.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot strict=on -device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x4 -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.0,addr=0x3 -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x6.0x7 -drive file=/var/lib/libvirt/images/r7.img,if=none,id=drive-virtio-disk0,format=raw,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x8,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=23,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:5a:a0:8c,bus=pci.0,addr=0x5 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -spice port=5900,addr=127.0.0.1,disable-ticketing,seamless-migration=on -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vgamem_mb=8,bus=pci.0,addr=0x2 -device intel-hda,id=sound0,bus=pci.0,addr=0x7 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x9 -msg timestamp=on
root       573  0.0  0.0 112644   964 pts/0    S+   13:40   0:00 grep --color=auto qemu


'invtsc' can not be found.

10.[root@localhost songwang]# virsh save aa aa.save

Domain aa saved to aa.save


Actual results:
as steps

Expected results:
fix it

Comment 2 Ján Tomko 2015-01-15 11:58:00 UTC
My commit dd324bb2703b9cf619c521b2a04f186cd9734f0a
    Do not format CPU features without a model
git describe: v1.2.11-rc2-5-g15abebd
which was backported for bug 1151885
relied on commit addce06c9221f948072cd222b56ea9c3f70ec066
    PowerPC : Add support for launching VM in 'compat' mode.
git describe: v1.2.10-40-gaddce06 which wasn't.

Without it, the features are only formatted for 'custom' mode CPU.

Comment 5 Song Wang 2015-01-22 05:57:26 UTC
Verify it as follows:

1.[root@localhost songwang]# rpm -q libvirt
libvirt-1.2.8-15.el7.x86_64

2.[root@localhost songwang]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     aa                             shut off

3.add these to xml.
 <cpu mode='host-model'>
    <model fallback='allow'/>
    <feature policy='require' name='invtsc'/>
  </cpu>

4.[root@localhost songwang]# virsh start aa
Domain aa started

5.[root@localhost songwang]# virsh dumpxml aa |grep cpu -A5
--
  <cpu mode='host-model'>
    <model fallback='allow'/>
    <feature policy='require' name='invtsc'/>
  </cpu>

6.[root@localhost songwang]# ps aux |grep qemu
qemu     23008 15.7  3.8 1914748 297604 ?      Sl   13:50   0:20 /usr/libexec/qemu-kvm -name aa -S -machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -cpu SandyBridge,+invtsc,+erms,+smep,+fsgsbase,+rdrand,+f16c,+osxsave,+pcid,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme -m 1024 -realtime mlock=off -smp 4,sockets=4,cores=1,threads=1 -uuid 23d19d5a-ee01-4a2b-bec9-948fca512c00 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/aa.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot strict=on -device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x3 -device nec-usb-xhci,id=usb,bus=pci.0,addr=0x6 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4 -drive file=/var/lib/libvirt/images/r7.qcow2,if=none,id=drive-ide0-0-0,format=qcow2,cache=none -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -netdev tap,fds=23:24:25:26:27,id=hostnet0,vhost=on,vhostfds=28:29:30:31:32 -device virtio-net-pci,ioeventfd=on,event_idx=on,mq=on,vectors=12,netdev=hostnet0,id=net0,mac=52:54:00:c9:7d:a5,bus=pci.0,addr=0x5 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -spice port=5900,addr=127.0.0.1,disable-ticketing,seamless-migration=on -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vgamem_mb=8,bus=pci.0,addr=0x2 -device intel-hda,id=sound0,bus=pci.0,addr=0x7 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x9 -msg timestamp=on
root     23195  0.0  0.0 112640   964 pts/0    S+   13:52   0:00 grep --color=auto qemu


7.[root@localhost songwang]# virsh destroy aa
Domain aa destroyed

8.[root@localhost songwang]# virsh start aa
Domain aa started


9.[root@localhost songwang]# virsh dumpxml aa |grep cpu -A5
--
  <cpu mode='host-model'>
    <model fallback='allow'/>
    <feature policy='require' name='invtsc'/>
  </cpu>

10.[root@localhost songwang]# ps aux |grep qemu
qemu     23317 17.8  3.7 1914748 295708 ?      Sl   13:53   0:20 /usr/libexec/qemu-kvm -name aa -S -machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -cpu SandyBridge,+invtsc,+erms,+smep,+fsgsbase,+rdrand,+f16c,+osxsave,+pcid,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme -m 1024 -realtime mlock=off -smp 4,sockets=4,cores=1,threads=1 -uuid 23d19d5a-ee01-4a2b-bec9-948fca512c00 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/aa.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot strict=on -device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x3 -device nec-usb-xhci,id=usb,bus=pci.0,addr=0x6 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4 -drive file=/var/lib/libvirt/images/r7.qcow2,if=none,id=drive-ide0-0-0,format=qcow2,cache=none -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -netdev tap,fds=23:24:25:26:27,id=hostnet0,vhost=on,vhostfds=28:29:30:31:32 -device virtio-net-pci,ioeventfd=on,event_idx=on,mq=on,vectors=12,netdev=hostnet0,id=net0,mac=52:54:00:c9:7d:a5,bus=pci.0,addr=0x5 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -spice port=5900,addr=127.0.0.1,disable-ticketing,seamless-migration=on -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vgamem_mb=8,bus=pci.0,addr=0x2 -device intel-hda,id=sound0,bus=pci.0,addr=0x7 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x9 -msg timestamp=on
root     23480  0.0  0.0 112640   964 pts/0    S+   13:54   0:00 grep --color=auto qemu


bug is fixed ,so change the state to VERIFIED

Comment 6 Song Wang 2015-01-22 06:01:04 UTC
additional test:


[root@localhost songwang]# virsh start aa
Domain aa started


[root@localhost songwang]# virsh save aa aa.save
error: Failed to save domain aa to aa.save
error: Requested operation is not valid: domain has CPU feature: invtsc

Comment 8 errata-xmlrpc 2015-03-05 07:49:10 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/RHSA-2015-0323.html