mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Cpu mode host-passthrough allows topology and features (#1423)
When cpu mode was set to host-passthrough the template would skip setting all other settings for the cpu, while it appears from the documentation that it supports use of feature elements, and testing confirms that it also supports the topology element. https://libvirt.org/formatdomain.html#cpu-model-and-topology Fixes: #975
This commit is contained in:
@@ -628,6 +628,21 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
||||
assert_invalid
|
||||
end
|
||||
end
|
||||
|
||||
context 'with cpu_mode and cpu_model defined' do
|
||||
it 'should discard model if mode is passthrough' 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
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#merge' do
|
||||
|
||||
39
spec/unit/templates/domain_cpu_mode_passthrough.xml
Normal file
39
spec/unit/templates/domain_cpu_mode_passthrough.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<domain type='' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
|
||||
<name></name>
|
||||
<title></title>
|
||||
<description></description>
|
||||
<uuid></uuid>
|
||||
<memory></memory>
|
||||
<vcpu>1</vcpu>
|
||||
<cpu mode='host-passthrough'>
|
||||
<feature policy='optional' name='vmx'/>
|
||||
<feature policy='optional' name='svm'/>
|
||||
<topology sockets='1' cores='2' threads='1'/>
|
||||
</cpu>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
<kernel></kernel>
|
||||
<initrd></initrd>
|
||||
<cmdline></cmdline>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
<pae/>
|
||||
</features>
|
||||
<clock offset='utc'>
|
||||
</clock>
|
||||
<devices>
|
||||
<serial type='pty'>
|
||||
<target port='0'/>
|
||||
</serial>
|
||||
<console type='pty'>
|
||||
<target port='0'/>
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='9216' heads='1'/>
|
||||
</video>
|
||||
</devices>
|
||||
</domain>
|
||||
@@ -129,15 +129,31 @@ describe 'templates/domain' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when custom cpu model enabled' do
|
||||
before do
|
||||
domain.cpu_mode = 'custom'
|
||||
domain.cpu_model = 'SandyBridge'
|
||||
context 'when cpu mode is set' do
|
||||
context 'to host-passthrough' do
|
||||
before do
|
||||
domain.cpu_mode = 'host-passthrough'
|
||||
domain.cpu_model = 'SandyBridge'
|
||||
domain.cputopology :sockets => '1', :cores => '2', :threads => '1'
|
||||
domain.nested = true
|
||||
end
|
||||
let(:test_file) { 'domain_cpu_mode_passthrough.xml' }
|
||||
it 'should allow features and topology and ignore model' do
|
||||
domain.finalize!
|
||||
expect(domain.to_xml('domain')).to eq xml_expected
|
||||
end
|
||||
end
|
||||
let(:test_file) { 'domain_custom_cpu_model.xml' }
|
||||
it 'renders template' do
|
||||
domain.finalize!
|
||||
expect(domain.to_xml('domain')).to eq xml_expected
|
||||
|
||||
context 'to custom and model is set' do
|
||||
before do
|
||||
domain.cpu_mode = 'custom'
|
||||
domain.cpu_model = 'SandyBridge'
|
||||
end
|
||||
let(:test_file) { 'domain_custom_cpu_model.xml' }
|
||||
it 'renders template' do
|
||||
domain.finalize!
|
||||
expect(domain.to_xml('domain')).to eq xml_expected
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user