Bug 956468

Summary: cpu 'host-model' should support features in force or disable mode
Product: Red Hat Enterprise Linux 7 Reporter: Wayne Sun <gsun>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: acathrow, crobinso, cwei, dallan, dfediuck, dyuan, honzhang, jmiao, mzhan, pbonzini, rjones, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.1.1-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 870484
: 1059007 (view as bug list) Environment:
Last Closed: 2014-06-13 10:57:28 UTC Type: ---
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: 799354, 870484    
Bug Blocks: 865505, 1059007    

Description Wayne Sun 2013-04-25 03:29:24 UTC
This also exist on
libvirt-1.0.4-1.el7.x86_64

+++ This bug was initially created as a clone of Bug #870484 +++

+++ This bug was initially created as a clone of Bug #799354 +++

Would be handy to have <cpu mode='host-model'> support <feature policy='force'/> or policy=disable. That way tools have an option to turn on x2apic for kvm guests which provides a performance boost with no downsides, but doesn't require host CPU support.

--- Additional comment from rjones on 2012-10-25 14:05:16 EDT ---

Also <feature policy='disable'/>.  For one use case, see:
https://bugzilla.redhat.com/show_bug.cgi?id=870071#c2

--- Additional comment from Jiri Denemark on 2012-10-29 09:13:31 EDT ---

I'm the owner of upstream brother of this bug.

--- Additional comment from Andrew Cathrow on 2012-12-31 17:11:37 EST ---

Depending on the implementation of this we may want to close 891015 which covers host passthrough mode.

Comment 2 Peter Krempa 2013-07-16 09:13:24 UTC
Fixed upstream with:

commit 3c8be55c04eb2647fd5c9d51efae78f7afdcec85
Author: Peter Krempa <pkrempa>
Date:   Mon Jul 15 17:38:55 2013 +0200

    cpu: Allow fine tuning of "host-model" cpu
    
    https://bugzilla.redhat.com/show_bug.cgi?id=799354
    
    Until now, the "host-model" cpu mode couldn't be influenced. This patch
    allows to use the <feature> elements to either enable or disable
    specific CPU flags. This can be used to force flags that can be emulated
    even if the host CPU doesn't support them.

commit 13cdd389ed06e81277f208c269d825046cdbb4cb
Author: Peter Krempa <pkrempa>
Date:   Mon Jul 15 14:36:09 2013 +0200

    cpu: Add virCPUDefUpdateFeature()
    
    This new function updates or adds a feature to a existing cpu model
    definition. This function will be helpful to allow tuning of
    "host-model" features in later patches.

v1.1.0-193-g3c8be55

Moving to POST.

Comment 3 Jincheng Miao 2013-07-31 08:32:14 UTC
bug fix verification:
1. add cpu feature policy in xml

# virsh edit guest
  <cpu mode='host-model'>
    <model fallback='allow'/>
    <feature policy='force' name='avx'/>
  </cpu>


# virsh start guest
Domain guest started

2. check avx in guest:
[root@guest ~]# cat /proc/cpuinfo | grep avx
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc up arch_perfmon rep_good unfair_spinlock pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm xsaveopt fsgsbase smep erms

3.
# virsh destroy guest
Domain guest destroyed

4. change cpu feature policy
# virsh edit guest
  <cpu mode='host-model'>
    <model fallback='allow'/>
    <feature policy='disable' name='avx'/>
  </cpu>

5. check avx in guest:
[root@guest ~]# cat /proc/cpuinfo | grep avx
 <no output>

6. check qemu arguments
# ps -ef | grep avx
qemu     14664     1  1 16:09 ?        00:00:12 /usr/libexec/qemu-kvm -name guest -S -machine pc-i440fx-rhel7.0.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,-avx -m 1024 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid c43be7a8-e950-a68a-813f-40c7d771167d -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/guest.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/libvirt/images/r7m.img,if=none,id=drive-virtio-disk0,format=qcow2,cache=writethrough -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=28,id=hostnet0,vhost=on,vhostfd=30 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:e8:c9:02,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -vga cirrus -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
we can see there is "-avx" in qemu arguments.

According above, libvirt can handle cpu feature policy. So change the status to VERIFIED.

Comment 4 Ludek Smid 2014-06-13 10:57:28 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.