Add support for configuring memballoon-related settings (#1083)

Allow configuration of various memballoon-related settings. It was 
discovered that it may be needed to be able to control the memballoon's 
PCI slot/bus location in order to prevent it from conflicting with 
other explicit PCI location assignments. For example when configuring 
the management network NIC to go to slot 0x05, libvirt would try to put 
the memballoon there as well and resulting in a fatal error.
This commit is contained in:
Edmund Rhudy
2020-12-15 12:40:05 -05:00
committed by GitHub
parent ac2c857599
commit a11750cc3b
4 changed files with 96 additions and 0 deletions

View File

@@ -129,4 +129,54 @@ describe 'templates/domain' do
expect(domain.to_xml('domain')).to eq xml_expected
end
end
context 'memballoon' do
context 'default' do
it 'renders without specifying the xml tag' do
domain.finalize!
expect(domain.to_xml('domain')).to_not match(/memballoon/)
end
end
context 'memballon enabled' do
before do
domain.memballoon_enabled = true
end
it 'renders with memballon element' do
domain.finalize!
expect(domain.to_xml('domain')).to match(/<memballoon model='virtio'>/)
expect(domain.to_xml('domain')).to match(/<address type='pci' domain='0x0000' bus='0x00' slot='0x0f' function='0x0'\/>/)
end
context 'all settings specified' do
before do
domain.memballoon_model = "virtio-non-transitional"
domain.memballoon_pci_bus = "0x01"
domain.memballoon_pci_slot = "0x05"
end
it 'renders with specified values' do
domain.finalize!
expect(domain.to_xml('domain')).to match(/<memballoon model='virtio-non-transitional'>/)
expect(domain.to_xml('domain')).to match(/<address type='pci' domain='0x0000' bus='0x01' slot='0x05' function='0x0'\/>/)
end
end
end
context 'memballon disabled' do
before do
domain.memballoon_enabled = false
end
it 'renders the memballoon element with model none' do
domain.finalize!
expect(domain.to_xml('domain')).to match(/<memballoon model='none'\/>/)
end
end
end
end