Add support for spinlocks hyperv feature

This commit is contained in:
Zdenek Zambersky
2019-09-04 20:57:15 +02:00
parent 98ff2dfb51
commit 3b1b17a5c9
6 changed files with 22 additions and 4 deletions

View File

@@ -1258,6 +1258,8 @@ Vagrant.configure("2") do |config|
libvirt.hyperv_feature :name => 'relaxed', :state => 'on'
# Enable virtual APIC
libvirt.hyperv_feature :name => 'vapic', :state => 'on'
# Enable spinlocks (requires retries to be specified)
libvirt.hyperv_feature :name => 'spinlocks', :state => 'on', :retries => '8191'
end
end
```

View File

@@ -237,8 +237,12 @@ module VagrantPlugins
env[:ui].info(" -- Feature: #{feature}")
end
@features_hyperv.each do |feature|
if feature[:name] == 'spinlocks'
env[:ui].info(" -- Feature (HyperV): name=#{feature[:name]}, state=#{feature[:state]}, retries=#{feature[:retries]}")
else
env[:ui].info(" -- Feature (HyperV): name=#{feature[:name]}, state=#{feature[:state]}")
end
end
env[:ui].info(" -- Clock offset: #{@clock_offset}")
@clock_timers.each do |timer|
env[:ui].info(" -- Clock timer: #{timer.map { |k,v| "#{k}=#{v}"}.join(', ')}")

View File

@@ -398,11 +398,21 @@ module VagrantPlugins
raise 'Feature name AND state must be specified'
end
if options[:name] == 'spinlocks' && options[:retries].nil?
raise 'Feature spinlocks requires retries parameter'
end
@features_hyperv = [] if @features_hyperv == UNSET_VALUE
if options[:name] == 'spinlocks'
@features_hyperv.push(name: options[:name],
state: options[:state],
retries: options[:retries])
else
@features_hyperv.push(name: options[:name],
state: options[:state])
end
end
def clock_timer(options = {})
if options[:name].nil?

View File

@@ -99,7 +99,7 @@
<% if !@features_hyperv.empty? %>
<hyperv>
<% @features_hyperv.each do |feature| %>
<<%= feature[:name] %> state='<%= feature[:state] %>' />
<<%= feature[:name] %> state='<%= feature[:state] %>'<% if feature[:name] == 'spinlocks' %> retries='<%= feature[:retries] %>'<% end %> />
<% end %>
</hyperv>
<% end %>

View File

@@ -34,6 +34,7 @@
<pae/>
<hyperv>
<BBB state='on' />
<spinlocks state='on' retries='4096' />
</hyperv>
</features>
<clock offset='variable'>

View File

@@ -43,6 +43,7 @@ describe 'templates/domain' do
domain.clock_offset = 'variable'
domain.clock_timer(name: 't1')
domain.clock_timer(name: 't2', track: 'b', tickpolicy: 'c', frequency: 'd', mode: 'e', present: 'yes')
domain.hyperv_feature(name: 'spinlocks', state: 'on', retries: '4096')
domain.cputopology(sockets: '1', cores: '3', threads: '2')
domain.machine_type = 'pc-compatible'
domain.machine_arch = 'x86_64'