mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Reject cpu features enabled without model (#1658)
Recent Libvirt will silently drop cpu features set without a model defined. Ensure this scenario is flagged as being invalid up front. Fixes: #996
This commit is contained in:
@@ -1109,6 +1109,10 @@ module VagrantPlugins
|
||||
errors << "cannot set cpu_model with cpu_mode of 'host-passthrough'. leave model unset or switch mode."
|
||||
end
|
||||
|
||||
unless @cpu_model != '' || @cpu_features.empty?
|
||||
errors << "cannot set cpu_features with cpu_model unset, please set a model or skip setting features."
|
||||
end
|
||||
|
||||
# The @uri and @qemu_use_session should not conflict
|
||||
uri = _parse_uri(@uri)
|
||||
if (uri.scheme.start_with? "qemu") && (uri.path.include? "session")
|
||||
|
||||
@@ -857,18 +857,30 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
||||
end
|
||||
end
|
||||
|
||||
context 'with cpu_mode and cpu_model defined' do
|
||||
it 'should discard model if mode is passthrough' do
|
||||
context 'with cpu_mode defined' do
|
||||
before do
|
||||
subject.cpu_mode = 'host-passthrough'
|
||||
subject.cpu_model = 'qemu64'
|
||||
assert_valid
|
||||
expect(subject.cpu_model).to be_empty
|
||||
end
|
||||
|
||||
it 'should allow custom mode with model' do
|
||||
subject.cpu_mode = 'custom'
|
||||
subject.cpu_model = 'qemu64'
|
||||
assert_valid
|
||||
context 'with cpu_model defined' do
|
||||
it 'should discard model if mode is passthrough' do
|
||||
subject.cpu_model = 'qemu64'
|
||||
assert_valid
|
||||
expect(subject.cpu_model).to be_empty
|
||||
end
|
||||
|
||||
it 'should allow custom mode with model' do
|
||||
subject.cpu_mode = 'custom'
|
||||
subject.cpu_model = 'qemu64'
|
||||
assert_valid
|
||||
end
|
||||
end
|
||||
|
||||
context 'with cpu_model not defined' do
|
||||
it 'should reject if cpu features enabled' do
|
||||
subject.cpu_features = [{:name => 'feature', :policy => 'optional'}]
|
||||
assert_invalid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user