Ensure explicit setting of inputs respected (#1619)

Make sure that explicit defining of input devices prevents injection of
the default mouse using ps/2 entry.

Fixes: #1092
This commit is contained in:
Darragh Bailey
2022-09-30 17:06:59 +01:00
committed by GitHub
parent c0ce667a31
commit 3599fd7600
2 changed files with 35 additions and 0 deletions

View File

@@ -1100,6 +1100,8 @@ module VagrantPlugins
result.disk_driver_opts = disk_driver_opts.merge(other.disk_driver_opts)
result.inputs = inputs != UNSET_VALUE ? inputs.dup + (other.inputs != UNSET_VALUE ? other.inputs : []) : other.inputs
c = sysinfo == UNSET_VALUE ? {} : sysinfo.dup
c.merge!(other.sysinfo) { |_k, x, y| x.respond_to?(:each_pair) ? x.merge(y) : x + y } if other.sysinfo != UNSET_VALUE
result.sysinfo = c

View File

@@ -580,6 +580,22 @@ describe VagrantPlugins::ProviderLibvirt::Config do
end
end
end
context '@inputs' do
it 'should contain ps/2 mouse by default' do
subject.finalize!
expect(subject.inputs).to eq([{:bus=>"ps2", :type=>"mouse"}])
end
it 'should contain only the specific entries' do
subject.input :type => "keyboard", :bus => "usb"
subject.finalize!
expect(subject.inputs).to eq([{:bus=>"usb", :type=>"keyboard"}])
end
end
end
def assert_invalid
@@ -887,5 +903,22 @@ describe VagrantPlugins::ProviderLibvirt::Config do
expect(subject.boot_order).to eq(['hd', 'cdrom'])
end
end
context 'inputs' do
it 'should merge' do
one.input :type => "tablet", :bus => "usb"
two.input :type => "keyboard", :bus => "usb"
subject.finalize!
expect(subject.inputs).to eq([{:type => "tablet", :bus => "usb"}, {:type => "keyboard", :bus => "usb"}])
end
it 'should respect explicit blanking' do
one.inputs = []
subject.finalize!
expect(subject.inputs).to eq([])
end
end
end
end