adrahon / vagrant-kvm

This project is dead, please use vagrant-libvirt instead! A Vagrant 1.4+ plugin that adds a KVM provider to Vagrant, allowing Vagrant to control and provision KVM/QEMU VM.
MIT License
366 stars 60 forks source link

Issue #270: Add control for cpu_model and cpu_feature. #272

Open tpodowd opened 9 years ago

tpodowd commented 9 years ago

Add configuration parameters for cpu_model and cpu_feature which control the setting of the following xml block.

<cpu mode='custom' match='exact'>
    <model fallback='allow'>core2duo</model>
    <feature policy='require' name='vmx'/>
</cpu>

This allows a vagrant KVM guest to provide nested virtualization.

NOTE: The cpu_model parameter was previously was listed to define the cpu architecture but it actually was not doing anything. This parameter has been reused to reflect the preferred guest cpu model.

tpodowd commented 9 years ago

Here's a snippet showing the feature is working against a vagrant guest.

$ sudo virsh dumpxml 34 | grep -A 4 '<cpu'
<cpu mode='custom' match='exact'>
     <model fallback='allow'>core2duo</model>
     <feature policy='require' name='vmx'/>
     <feature policy='require' name='ht'/>
</cpu>

Also if I log in to the box, I can see the following.

[vagrant@cloud1 ~]$ egrep '(vmx|svm)' --color=always /proc/cpuinfo
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 lm constant_tsc up arch_perfmon rep_good unfair_spinlock pni vmx ssse3 cx16 hypervisor lahf_lm vnmi ept

So, it seems to be working. I can also halt and destroy.

celebdor commented 9 years ago

I tested it on arch linux and it works well for me ;-) Thanks @tpodowd

tpodowd commented 9 years ago

Awesome. Thanks @celebdor. Hopefully it will get merged soon. It seems to be working well for me also.