Floppy support (#1334)

Add support for attaching 1 or 2 floppy drives to the VM using "vfd"
image files.
This commit is contained in:
Oded Arbel
2022-10-08 13:59:06 +03:00
committed by GitHub
parent 35e3730abf
commit d38e130f47
8 changed files with 142 additions and 2 deletions

View File

@@ -20,7 +20,7 @@ class EnvironmentHelper
1024
end
%w(cpus cpu_mode loader nvram boot_order machine_type disk_bus disk_device nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms driver).each do |name|
%w(cpus cpu_mode loader nvram boot_order machine_type disk_bus disk_device nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms floppies driver).each do |name|
define_method(name.to_sym) do
nil
end

View File

@@ -873,6 +873,26 @@ describe VagrantPlugins::ProviderLibvirt::Config do
end
end
end
context 'with cdroms and floppies' do
it 'should be invalid if too many cdroms' do
subject.storage :file, :device => :cdrom
subject.storage :file, :device => :cdrom
subject.storage :file, :device => :cdrom
subject.storage :file, :device => :cdrom
subject.storage :file, :device => :cdrom
expect{ subject.finalize! }.to raise_error('Only four cdroms may be attached at a time')
end
it 'sould be invalid if too many floppies' do
subject.storage :file, :device => :floppy
subject.storage :file, :device => :floppy
subject.storage :file, :device => :floppy
expect{ subject.finalize! }.to raise_error('Only two floppies may be attached at a time')
end
end
end
describe '#merge' do
@@ -925,6 +945,28 @@ describe VagrantPlugins::ProviderLibvirt::Config do
end
end
end
context 'with floppies only' do
context 'assigned specific devs' do
it 'should merge floppies with specific devices' do
one.storage(:file, device: :floppy, dev: 'fda')
two.storage(:file, device: :floppy, dev: 'fdb')
subject.finalize!
expect(subject.floppies).to include(include(dev: 'fda'),
include(dev: 'fdb'))
end
end
context 'without devs given' do
it 'should merge floppies with different devs assigned automatically' do
one.storage(:file, device: :floppy)
two.storage(:file, device: :floppy)
subject.finalize!
expect(subject.floppies).to include(include(dev: 'fda'),
include(dev: 'fdb'))
end
end
end
end
context 'clock_timers' do

View File

@@ -85,6 +85,10 @@
<target dev='hdb' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='floppy'>
<source file=''/>
<target dev='fda' bus='fdc'/>
</disk>
<serial type='file'>
<source path='/var/log/vm_consoles/machine.log'/>
<target port='0'/>

View File

@@ -81,6 +81,7 @@ describe 'templates/domain' do
domain.disk_driver(:cache => 'unsafe', :io => 'threads', :copy_on_read => 'on', :discard => 'unmap', :detect_zeroes => 'on')
domain.storage(:file, path: 'test-disk1.qcow2')
domain.storage(:file, path: 'test-disk2.qcow2', io: 'threads', copy_on_read: 'on', discard: 'unmap', detect_zeroes: 'on')
domain.storage(:file, device: :floppy)
domain.storage(:file, device: :cdrom)
domain.storage(:file, device: :cdrom)
domain.channel(type: 'unix',