vagrant-libvirt 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +51 -2079
- data/lib/vagrant-libvirt/action/create_domain.rb +39 -4
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +1 -1
- data/lib/vagrant-libvirt/action/create_networks.rb +3 -3
- data/lib/vagrant-libvirt/action/destroy_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/destroy_networks.rb +1 -1
- data/lib/vagrant-libvirt/action/handle_box_image.rb +1 -1
- data/lib/vagrant-libvirt/action/package_domain.rb +1 -5
- data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +3 -1
- data/lib/vagrant-libvirt/action/resolve_disk_settings.rb +15 -8
- data/lib/vagrant-libvirt/action/snapshot_delete.rb +26 -0
- data/lib/vagrant-libvirt/action/snapshot_restore.rb +22 -0
- data/lib/vagrant-libvirt/action/snapshot_save.rb +27 -0
- data/lib/vagrant-libvirt/action/start_domain.rb +43 -14
- data/lib/vagrant-libvirt/action.rb +49 -1
- data/lib/vagrant-libvirt/cap/snapshots.rb +12 -0
- data/lib/vagrant-libvirt/cap/synced_folder_9p.rb +4 -4
- data/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb +4 -4
- data/lib/vagrant-libvirt/config.rb +101 -6
- data/lib/vagrant-libvirt/driver.rb +108 -46
- data/lib/vagrant-libvirt/errors.rb +23 -3
- data/lib/vagrant-libvirt/plugin.rb +7 -3
- data/lib/vagrant-libvirt/provider.rb +1 -1
- data/lib/vagrant-libvirt/templates/domain.xml.erb +30 -4
- data/lib/vagrant-libvirt/util/byte_number.rb +0 -1
- data/lib/vagrant-libvirt/util/compat.rb +23 -0
- data/lib/vagrant-libvirt/util/unindent.rb +7 -0
- data/lib/vagrant-libvirt/version +1 -1
- data/locales/en.yml +24 -2
- data/spec/acceptance/additional_storage_spec.rb +32 -0
- data/spec/acceptance/package_domain_spec.rb +90 -0
- data/spec/acceptance/provider_settings_spec.rb +54 -0
- data/spec/acceptance/simple_vm_provision_via_shell_spec.rb +31 -0
- data/spec/acceptance/snapshots_spec.rb +41 -0
- data/spec/acceptance/support-skeletons/package_complex/Vagrantfile.testbox +14 -0
- data/spec/acceptance/support-skeletons/package_complex/scripts/sysprep.sh +32 -0
- data/spec/acceptance/support-skeletons/package_simple/Vagrantfile.testbox +10 -0
- data/spec/acceptance/two_disks_spec.rb +29 -0
- data/spec/acceptance/use_qemu_agent_for_connectivity_spec.rb +35 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/acceptance/configuration.rb +21 -0
- data/spec/support/acceptance/context.rb +70 -0
- data/spec/support/acceptance/isolated_environment.rb +41 -0
- data/spec/support/libvirt_acceptance_context.rb +64 -0
- data/spec/support/sharedcontext.rb +1 -0
- data/spec/unit/action/create_domain_spec/sysinfo.xml +66 -0
- data/spec/unit/action/create_domain_spec/sysinfo_only_required.xml +49 -0
- data/spec/unit/action/create_domain_spec.rb +82 -0
- data/spec/unit/action/forward_ports_spec.rb +0 -1
- data/spec/unit/action/handle_box_image_spec.rb +18 -1
- data/spec/unit/action/remove_libvirt_image_spec.rb +43 -0
- data/spec/unit/action/resolve_disk_settings_spec.rb +24 -0
- data/spec/unit/action/start_domain_spec/clock_timer_removed.xml +38 -0
- data/spec/unit/action/start_domain_spec/clock_timer_rtc_tsc.xml +39 -0
- data/spec/unit/action/start_domain_spec/nvram_domain_other_setting.xml +2 -2
- data/spec/unit/action/start_domain_spec.rb +72 -30
- data/spec/unit/action_spec.rb +88 -0
- data/spec/unit/cap/synced_folder_9p_spec.rb +120 -0
- data/spec/unit/cap/synced_folder_virtiofs_spec.rb +120 -0
- data/spec/unit/config_spec.rb +133 -6
- data/spec/unit/driver_spec.rb +1 -1
- data/spec/unit/plugin_spec.rb +42 -0
- data/spec/unit/templates/domain_all_settings.xml +13 -4
- data/spec/unit/templates/domain_scsi_bus_storage.xml +44 -0
- data/spec/unit/templates/domain_scsi_device_storage.xml +44 -0
- data/spec/unit/templates/domain_scsi_multiple_controllers_storage.xml +130 -0
- data/spec/unit/templates/domain_spec.rb +105 -21
- data/spec/unit/util/byte_number_spec.rb +1 -1
- metadata +155 -87
- data/spec/unit/provider_spec.rb +0 -11
@@ -0,0 +1,130 @@
|
|
1
|
+
<domain type='' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
|
2
|
+
<name></name>
|
3
|
+
<title></title>
|
4
|
+
<description></description>
|
5
|
+
<uuid></uuid>
|
6
|
+
<memory></memory>
|
7
|
+
<vcpu>1</vcpu>
|
8
|
+
<cpu mode='host-model'>
|
9
|
+
<model fallback='allow'></model>
|
10
|
+
</cpu>
|
11
|
+
<os>
|
12
|
+
<type>hvm</type>
|
13
|
+
<kernel></kernel>
|
14
|
+
<initrd></initrd>
|
15
|
+
<cmdline></cmdline>
|
16
|
+
</os>
|
17
|
+
<features>
|
18
|
+
<acpi/>
|
19
|
+
<apic/>
|
20
|
+
<pae/>
|
21
|
+
</features>
|
22
|
+
<clock offset='utc'>
|
23
|
+
</clock>
|
24
|
+
<devices>
|
25
|
+
<disk type='file' device='disk'>
|
26
|
+
<alias name='ua-box-volume-0'/>
|
27
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
28
|
+
<source file='/var/lib/libvirt/images/test-1.img'/>
|
29
|
+
<target dev='sda' bus='scsi'/>
|
30
|
+
</disk>
|
31
|
+
<disk type='file' device='disk'>
|
32
|
+
<alias name='ua-box-volume-1'/>
|
33
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
34
|
+
<source file='/var/lib/libvirt/images/test-2.img'/>
|
35
|
+
<target dev='sdb' bus='scsi'/>
|
36
|
+
</disk>
|
37
|
+
<disk type='file' device='disk'>
|
38
|
+
<alias name='ua-box-volume-2'/>
|
39
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
40
|
+
<source file='/var/lib/libvirt/images/test-3.img'/>
|
41
|
+
<target dev='sdc' bus='scsi'/>
|
42
|
+
</disk>
|
43
|
+
<disk type='file' device='disk'>
|
44
|
+
<alias name='ua-box-volume-3'/>
|
45
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
46
|
+
<source file='/var/lib/libvirt/images/test-4.img'/>
|
47
|
+
<target dev='sdd' bus='scsi'/>
|
48
|
+
</disk>
|
49
|
+
<disk type='file' device='disk'>
|
50
|
+
<alias name='ua-box-volume-4'/>
|
51
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
52
|
+
<source file='/var/lib/libvirt/images/test-5.img'/>
|
53
|
+
<target dev='sde' bus='scsi'/>
|
54
|
+
</disk>
|
55
|
+
<disk type='file' device='disk'>
|
56
|
+
<alias name='ua-box-volume-5'/>
|
57
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
58
|
+
<source file='/var/lib/libvirt/images/test-6.img'/>
|
59
|
+
<target dev='sdf' bus='scsi'/>
|
60
|
+
</disk>
|
61
|
+
<disk type='file' device='disk'>
|
62
|
+
<alias name='ua-box-volume-6'/>
|
63
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
64
|
+
<source file='/var/lib/libvirt/images/test-7.img'/>
|
65
|
+
<target dev='sdg' bus='scsi'/>
|
66
|
+
</disk>
|
67
|
+
<disk type='file' device='disk'>
|
68
|
+
<alias name='ua-box-volume-7'/>
|
69
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
70
|
+
<source file='/var/lib/libvirt/images/test-8.img'/>
|
71
|
+
<target dev='sdh' bus='scsi'/>
|
72
|
+
</disk>
|
73
|
+
<disk type='file' device='disk'>
|
74
|
+
<alias name='ua-box-volume-8'/>
|
75
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
76
|
+
<source file='/var/lib/libvirt/images/test-9.img'/>
|
77
|
+
<target dev='sdi' bus='scsi'/>
|
78
|
+
</disk>
|
79
|
+
<disk type='file' device='disk'>
|
80
|
+
<alias name='ua-box-volume-9'/>
|
81
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
82
|
+
<source file='/var/lib/libvirt/images/test-10.img'/>
|
83
|
+
<target dev='sdj' bus='scsi'/>
|
84
|
+
</disk>
|
85
|
+
<disk type='file' device='disk'>
|
86
|
+
<alias name='ua-box-volume-10'/>
|
87
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
88
|
+
<source file='/var/lib/libvirt/images/test-11.img'/>
|
89
|
+
<target dev='sdk' bus='scsi'/>
|
90
|
+
</disk>
|
91
|
+
<disk type='file' device='disk'>
|
92
|
+
<alias name='ua-box-volume-11'/>
|
93
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
94
|
+
<source file='/var/lib/libvirt/images/test-12.img'/>
|
95
|
+
<target dev='sdl' bus='scsi'/>
|
96
|
+
</disk>
|
97
|
+
<disk type='file' device='disk'>
|
98
|
+
<alias name='ua-box-volume-12'/>
|
99
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
100
|
+
<source file='/var/lib/libvirt/images/test-13.img'/>
|
101
|
+
<target dev='sdm' bus='scsi'/>
|
102
|
+
</disk>
|
103
|
+
<disk type='file' device='disk'>
|
104
|
+
<alias name='ua-box-volume-13'/>
|
105
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
106
|
+
<source file='/var/lib/libvirt/images/test-14.img'/>
|
107
|
+
<target dev='sdn' bus='scsi'/>
|
108
|
+
</disk>
|
109
|
+
<disk type='file' device='disk'>
|
110
|
+
<alias name='ua-box-volume-14'/>
|
111
|
+
<driver name='qemu' type='qcow2' cache='unsafe'/>
|
112
|
+
<source file='/var/lib/libvirt/images/test-15.img'/>
|
113
|
+
<target dev='sdo' bus='scsi'/>
|
114
|
+
</disk>
|
115
|
+
<controller type='scsi' model='virtio-scsi' index='0'/>
|
116
|
+
<controller type='scsi' model='virtio-scsi' index='1'/>
|
117
|
+
<controller type='scsi' model='virtio-scsi' index='2'/>
|
118
|
+
<serial type='pty'>
|
119
|
+
<target port='0'/>
|
120
|
+
</serial>
|
121
|
+
<console type='pty'>
|
122
|
+
<target port='0'/>
|
123
|
+
</console>
|
124
|
+
<input type='mouse' bus='ps2'/>
|
125
|
+
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
126
|
+
<video>
|
127
|
+
<model type='cirrus' vram='16384' heads='1'/>
|
128
|
+
</video>
|
129
|
+
</devices>
|
130
|
+
</domain>
|
@@ -16,13 +16,33 @@ describe 'templates/domain' do
|
|
16
16
|
def initialize
|
17
17
|
super
|
18
18
|
@domain_volumes = []
|
19
|
+
@sysinfo_blocks = {
|
20
|
+
'bios' => {:section => "BIOS", :xml => "bios"},
|
21
|
+
'system' => {:section => "System", :xml => "system"},
|
22
|
+
'base board' => {:section => "Base Board", :xml => "baseBoard"},
|
23
|
+
'chassis' => {:section => "Chassis", :xml => "chassis"},
|
24
|
+
'oem strings' => {:section => "OEM Strings", :xml => "oemStrings"},
|
25
|
+
}
|
19
26
|
end
|
20
27
|
|
21
28
|
def finalize!
|
22
29
|
super
|
30
|
+
|
31
|
+
disks.each do |disk|
|
32
|
+
disk[:absolute_path] = '/var/lib/libvirt/images/' + disk[:path]
|
33
|
+
end
|
23
34
|
end
|
24
35
|
end
|
25
36
|
|
37
|
+
def resolve
|
38
|
+
# resolving is now done during create domain, so need to recreate
|
39
|
+
# the same behaviour before calling the template until that
|
40
|
+
# is separated out from create domain.
|
41
|
+
resolver = ::VagrantPlugins::ProviderLibvirt::Util::DiskDeviceResolver.new(prefix=domain.disk_device[0..1])
|
42
|
+
resolver.resolve!(domain.domain_volumes.dup.each { |volume| volume[:device] = volume[:dev] })
|
43
|
+
resolver.resolve!(domain.disks)
|
44
|
+
end
|
45
|
+
|
26
46
|
let(:domain) { DomainTemplateHelper.new }
|
27
47
|
let(:xml_expected) { File.read(File.join(File.dirname(__FILE__), test_file)) }
|
28
48
|
|
@@ -58,23 +78,8 @@ describe 'templates/domain' do
|
|
58
78
|
domain.disk_bus = 'ide'
|
59
79
|
domain.disk_device = 'vda'
|
60
80
|
domain.disk_driver(:cache => 'unsafe', :io => 'threads', :copy_on_read => 'on', :discard => 'unmap', :detect_zeroes => 'on')
|
61
|
-
domain.domain_volumes.push({
|
62
|
-
:dev => 'vda',
|
63
|
-
:cache => 'unsafe',
|
64
|
-
:bus => domain.disk_bus,
|
65
|
-
:absolute_path => '/var/lib/libvirt/images/test.qcow2'
|
66
|
-
})
|
67
|
-
domain.domain_volumes.push({
|
68
|
-
:dev => 'vdb',
|
69
|
-
:cache => 'unsafe',
|
70
|
-
:bus => domain.disk_bus,
|
71
|
-
:absolute_path => '/var/lib/libvirt/images/test2.qcow2'
|
72
|
-
})
|
73
81
|
domain.storage(:file, path: 'test-disk1.qcow2')
|
74
82
|
domain.storage(:file, path: 'test-disk2.qcow2', io: 'threads', copy_on_read: 'on', discard: 'unmap', detect_zeroes: 'on')
|
75
|
-
domain.disks.each do |disk|
|
76
|
-
disk[:absolute_path] = '/var/lib/libvirt/images/' + disk[:path]
|
77
|
-
end
|
78
83
|
domain.storage(:file, device: :cdrom)
|
79
84
|
domain.storage(:file, device: :cdrom)
|
80
85
|
domain.channel(type: 'unix',
|
@@ -102,6 +107,15 @@ describe 'templates/domain' do
|
|
102
107
|
domain.smartcard(mode: 'passthrough')
|
103
108
|
domain.tpm_path = '/dev/tpm0'
|
104
109
|
|
110
|
+
domain.sysinfo = {
|
111
|
+
'system' => {
|
112
|
+
'serial' => 'AAAAAAAA',
|
113
|
+
},
|
114
|
+
'oem strings' => [
|
115
|
+
'AAAAAAAA',
|
116
|
+
],
|
117
|
+
}
|
118
|
+
|
105
119
|
domain.qemuargs(value: '-device')
|
106
120
|
domain.qemuargs(value: 'dummy-device')
|
107
121
|
|
@@ -119,12 +133,18 @@ describe 'templates/domain' do
|
|
119
133
|
let(:test_file) { 'domain_all_settings.xml' }
|
120
134
|
it 'renders template' do
|
121
135
|
domain.finalize!
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
136
|
+
|
137
|
+
domain.domain_volumes.push({
|
138
|
+
:cache => 'unsafe',
|
139
|
+
:bus => domain.disk_bus,
|
140
|
+
:absolute_path => '/var/lib/libvirt/images/test.qcow2'
|
141
|
+
})
|
142
|
+
domain.domain_volumes.push({
|
143
|
+
:cache => 'unsafe',
|
144
|
+
:bus => domain.disk_bus,
|
145
|
+
:absolute_path => '/var/lib/libvirt/images/test2.qcow2'
|
146
|
+
})
|
147
|
+
resolve
|
128
148
|
|
129
149
|
expect(domain.to_xml('domain')).to eq xml_expected
|
130
150
|
end
|
@@ -231,4 +251,68 @@ describe 'templates/domain' do
|
|
231
251
|
end
|
232
252
|
end
|
233
253
|
end
|
254
|
+
|
255
|
+
context 'scsi controller' do
|
256
|
+
context 'when disk device suggests scsi' do
|
257
|
+
let(:test_file) { 'domain_scsi_device_storage.xml' }
|
258
|
+
|
259
|
+
before do
|
260
|
+
domain.disk_device = 'sda'
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'renders scsi controller in template' do
|
264
|
+
domain.finalize!
|
265
|
+
domain.domain_volumes.push({
|
266
|
+
:cache => 'unsafe',
|
267
|
+
:bus => domain.disk_bus,
|
268
|
+
:absolute_path => '/var/lib/libvirt/images/test.qcow2'
|
269
|
+
})
|
270
|
+
|
271
|
+
resolve
|
272
|
+
expect(domain.to_xml('domain')).to eq xml_expected
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
context 'when disk bus is scsi' do
|
277
|
+
let(:test_file) { 'domain_scsi_bus_storage.xml' }
|
278
|
+
|
279
|
+
before do
|
280
|
+
domain.disk_bus = 'scsi'
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'renders scsi controller in template based on bus' do
|
284
|
+
domain.finalize!
|
285
|
+
domain.domain_volumes.push({
|
286
|
+
:dev => 'vda',
|
287
|
+
:cache => 'unsafe',
|
288
|
+
:bus => domain.disk_bus,
|
289
|
+
:absolute_path => '/var/lib/libvirt/images/test.qcow2'
|
290
|
+
})
|
291
|
+
resolve
|
292
|
+
expect(domain.to_xml('domain')).to eq xml_expected
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
context 'when enough scsi disks are added' do
|
297
|
+
let(:test_file) { 'domain_scsi_multiple_controllers_storage.xml' }
|
298
|
+
|
299
|
+
before do
|
300
|
+
domain.disk_bus = 'scsi'
|
301
|
+
domain.disk_controller_model = 'virtio-scsi'
|
302
|
+
end
|
303
|
+
|
304
|
+
it 'should render with multiple scsi controllers' do
|
305
|
+
domain.finalize!
|
306
|
+
for idx in 1..15 do
|
307
|
+
domain.domain_volumes.push({
|
308
|
+
:cache => 'unsafe',
|
309
|
+
:bus => domain.disk_bus,
|
310
|
+
:absolute_path => "/var/lib/libvirt/images/test-#{idx}.img"
|
311
|
+
})
|
312
|
+
end
|
313
|
+
resolve
|
314
|
+
expect(domain.to_xml('domain')).to eq xml_expected
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
234
318
|
end
|