vagrant-libvirt 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +212 -27
  3. data/lib/vagrant-libvirt/action.rb +6 -0
  4. data/lib/vagrant-libvirt/action/clean_machine_folder.rb +28 -0
  5. data/lib/vagrant-libvirt/action/create_domain.rb +26 -10
  6. data/lib/vagrant-libvirt/action/create_domain_volume.rb +57 -55
  7. data/lib/vagrant-libvirt/action/create_network_interfaces.rb +0 -3
  8. data/lib/vagrant-libvirt/action/create_networks.rb +11 -4
  9. data/lib/vagrant-libvirt/action/destroy_domain.rb +1 -1
  10. data/lib/vagrant-libvirt/action/forward_ports.rb +36 -37
  11. data/lib/vagrant-libvirt/action/halt_domain.rb +25 -9
  12. data/lib/vagrant-libvirt/action/handle_box_image.rb +162 -74
  13. data/lib/vagrant-libvirt/action/is_running.rb +1 -3
  14. data/lib/vagrant-libvirt/action/is_suspended.rb +4 -4
  15. data/lib/vagrant-libvirt/action/wait_till_up.rb +1 -25
  16. data/lib/vagrant-libvirt/cap/{mount_p9.rb → mount_9p.rb} +2 -2
  17. data/lib/vagrant-libvirt/cap/mount_virtiofs.rb +37 -0
  18. data/lib/vagrant-libvirt/cap/{synced_folder.rb → synced_folder_9p.rb} +4 -5
  19. data/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb +109 -0
  20. data/lib/vagrant-libvirt/config.rb +24 -2
  21. data/lib/vagrant-libvirt/errors.rb +24 -1
  22. data/lib/vagrant-libvirt/plugin.rb +13 -5
  23. data/lib/vagrant-libvirt/templates/domain.xml.erb +7 -6
  24. data/lib/vagrant-libvirt/templates/private_network.xml.erb +1 -1
  25. data/lib/vagrant-libvirt/util/network_util.rb +21 -3
  26. data/lib/vagrant-libvirt/version +1 -1
  27. data/locales/en.yml +12 -0
  28. data/spec/spec_helper.rb +9 -1
  29. data/spec/support/matchers/have_file_content.rb +63 -0
  30. data/spec/unit/action/clean_machine_folder_spec.rb +48 -0
  31. data/spec/unit/action/create_domain_spec.rb +6 -0
  32. data/spec/unit/action/create_domain_volume_spec.rb +102 -0
  33. data/spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml +21 -0
  34. data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml +21 -0
  35. data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml +21 -0
  36. data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml +21 -0
  37. data/spec/unit/action/destroy_domain_spec.rb +1 -1
  38. data/spec/unit/action/forward_ports_spec.rb +202 -0
  39. data/spec/unit/action/halt_domain_spec.rb +90 -0
  40. data/spec/unit/action/handle_box_image_spec.rb +363 -0
  41. data/spec/unit/action/wait_till_up_spec.rb +1 -23
  42. data/spec/unit/templates/domain_all_settings.xml +8 -0
  43. data/spec/unit/templates/domain_spec.rb +20 -1
  44. metadata +41 -4
@@ -64,28 +64,9 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
64
64
  expect {subject.call(env) }.to raise_error(::Fog::Errors::TimeoutError)
65
65
  end
66
66
  end
67
-
68
- context 'if interrupted waiting for SSH' do
69
- before do
70
- allow(domain).to receive(:wait_for).and_return(true)
71
- allow(env).to receive(:[]).and_call_original
72
- allow(env).to receive(:[]).with(:interrupted).and_return(false, true, true)
73
- allow(driver).to receive(:get_domain_ipaddress).and_return('192.168.121.2')
74
- end
75
- it 'should exit after getting IP' do
76
- expect(app).to_not receive(:call)
77
- expect(ui).to receive(:info).with('Waiting for domain to get an IP address...')
78
- expect(ui).to receive(:info).with('Waiting for SSH to become available...')
79
- expect(logger).to receive(:debug).with(/Searching for IP for MAC address: .*/)
80
- expect(logger).to receive(:info).with('Got IP address 192.168.121.2')
81
- expect(logger).to receive(:info).with(/Time for getting IP: .*/)
82
- expect(env[:machine].communicate).to_not receive(:ready?)
83
- expect(subject.call(env)).to be_nil
84
- end
85
- end
86
67
  end
87
68
 
88
- context 'when machine boots and ssh available' do
69
+ context 'when machine boots and ip available' do
89
70
  before do
90
71
  allow(domain).to receive(:wait_for).and_return(true)
91
72
  allow(env).to receive(:[]).and_call_original
@@ -95,12 +76,9 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
95
76
  it 'should call the next hook' do
96
77
  expect(app).to receive(:call)
97
78
  expect(ui).to receive(:info).with('Waiting for domain to get an IP address...')
98
- expect(ui).to receive(:info).with('Waiting for SSH to become available...')
99
79
  expect(logger).to receive(:debug).with(/Searching for IP for MAC address: .*/)
100
80
  expect(logger).to receive(:info).with('Got IP address 192.168.121.2')
101
81
  expect(logger).to receive(:info).with(/Time for getting IP: .*/)
102
- expect(logger).to receive(:info).with(/Time for SSH ready: .*/)
103
- expect(env[:machine].communicate).to receive(:ready?).and_return(true)
104
82
  expect(subject.call(env)).to be_nil
105
83
  end
106
84
  end
@@ -34,6 +34,7 @@
34
34
  <pae/>
35
35
  <hyperv>
36
36
  <BBB state='on' />
37
+ <spinlocks state='on' retries='4096' />
37
38
  </hyperv>
38
39
  </features>
39
40
  <clock offset='variable'>
@@ -47,6 +48,11 @@
47
48
  <source file='/var/lib/libvirt/images/test.qcow2'/>
48
49
  <target dev='vda' bus='ide'/>
49
50
  </disk>
51
+ <disk type='file' device='disk'>
52
+ <driver name='qemu' type='qcow2' cache='unsafe' io='threads' copy_on_read='on' discard='unmap' detect_zeroes='on'/>
53
+ <source file='/var/lib/libvirt/images/test2.qcow2'/>
54
+ <target dev='vdb' bus='ide'/>
55
+ </disk>
50
56
  <disk type='file' device='disk'>
51
57
  <driver name='qemu' type='qcow2' cache='default'/>
52
58
  <source file='/var/lib/libvirt/images/test-disk1.qcow2'/>
@@ -59,11 +65,13 @@
59
65
  </disk>
60
66
 
61
67
  <disk type='file' device='cdrom'>
68
+ <driver name='qemu' type='raw' />
62
69
  <source file=''/>
63
70
  <target dev='hda' bus='ide'/>
64
71
  <readonly/>
65
72
  </disk>
66
73
  <disk type='file' device='cdrom'>
74
+ <driver name='qemu' type='raw' />
67
75
  <source file=''/>
68
76
  <target dev='hdb' bus='ide'/>
69
77
  <readonly/>
@@ -9,6 +9,13 @@ describe 'templates/domain' do
9
9
  class DomainTemplateHelper < VagrantPlugins::ProviderLibvirt::Config
10
10
  include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
11
11
 
12
+ attr_accessor :domain_volumes
13
+
14
+ def initialize
15
+ super
16
+ @domain_volumes = []
17
+ end
18
+
12
19
  def finalize!
13
20
  super
14
21
  end
@@ -36,6 +43,7 @@ describe 'templates/domain' do
36
43
  domain.clock_offset = 'variable'
37
44
  domain.clock_timer(name: 't1')
38
45
  domain.clock_timer(name: 't2', track: 'b', tickpolicy: 'c', frequency: 'd', mode: 'e', present: 'yes')
46
+ domain.hyperv_feature(name: 'spinlocks', state: 'on', retries: '4096')
39
47
  domain.cputopology(sockets: '1', cores: '3', threads: '2')
40
48
  domain.machine_type = 'pc-compatible'
41
49
  domain.machine_arch = 'x86_64'
@@ -44,11 +52,22 @@ describe 'templates/domain' do
44
52
  domain.boot('cdrom')
45
53
  domain.boot('hd')
46
54
  domain.emulator_path = '/usr/bin/kvm-spice'
47
- domain.instance_variable_set('@domain_volume_path', '/var/lib/libvirt/images/test.qcow2')
48
55
  domain.instance_variable_set('@domain_volume_cache', 'deprecated')
49
56
  domain.disk_bus = 'ide'
50
57
  domain.disk_device = 'vda'
51
58
  domain.disk_driver(:cache => 'unsafe', :io => 'threads', :copy_on_read => 'on', :discard => 'unmap', :detect_zeroes => 'on')
59
+ domain.domain_volumes.push({
60
+ :dev => 1.vdev.to_s,
61
+ :cache => 'unsafe',
62
+ :bus => domain.disk_bus,
63
+ :path => '/var/lib/libvirt/images/test.qcow2'
64
+ })
65
+ domain.domain_volumes.push({
66
+ :dev => 2.vdev.to_s,
67
+ :cache => 'unsafe',
68
+ :bus => domain.disk_bus,
69
+ :path => '/var/lib/libvirt/images/test2.qcow2'
70
+ })
52
71
  domain.storage(:file, path: 'test-disk1.qcow2')
53
72
  domain.storage(:file, path: 'test-disk2.qcow2', io: 'threads', copy_on_read: 'on', discard: 'unmap', detect_zeroes: 'on')
54
73
  domain.disks.each do |disk|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-libvirt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Stanek
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-04-03 00:00:00.000000000 Z
13
+ date: 2021-05-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec-core
@@ -110,6 +110,20 @@ dependencies:
110
110
  - - "~>"
111
111
  - !ruby/object:Gem::Version
112
112
  version: '2.1'
113
+ - !ruby/object:Gem::Dependency
114
+ name: rexml
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ type: :runtime
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
113
127
  - !ruby/object:Gem::Dependency
114
128
  name: nokogiri
115
129
  requirement: !ruby/object:Gem::Requirement
@@ -151,6 +165,7 @@ files:
151
165
  - README.md
152
166
  - lib/vagrant-libvirt.rb
153
167
  - lib/vagrant-libvirt/action.rb
168
+ - lib/vagrant-libvirt/action/clean_machine_folder.rb
154
169
  - lib/vagrant-libvirt/action/create_domain.rb
155
170
  - lib/vagrant-libvirt/action/create_domain_volume.rb
156
171
  - lib/vagrant-libvirt/action/create_network_interfaces.rb
@@ -183,10 +198,12 @@ files:
183
198
  - lib/vagrant-libvirt/action/start_domain.rb
184
199
  - lib/vagrant-libvirt/action/suspend_domain.rb
185
200
  - lib/vagrant-libvirt/action/wait_till_up.rb
186
- - lib/vagrant-libvirt/cap/mount_p9.rb
201
+ - lib/vagrant-libvirt/cap/mount_9p.rb
202
+ - lib/vagrant-libvirt/cap/mount_virtiofs.rb
187
203
  - lib/vagrant-libvirt/cap/nic_mac_addresses.rb
188
204
  - lib/vagrant-libvirt/cap/public_address.rb
189
- - lib/vagrant-libvirt/cap/synced_folder.rb
205
+ - lib/vagrant-libvirt/cap/synced_folder_9p.rb
206
+ - lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb
190
207
  - lib/vagrant-libvirt/config.rb
191
208
  - lib/vagrant-libvirt/driver.rb
192
209
  - lib/vagrant-libvirt/errors.rb
@@ -212,11 +229,21 @@ files:
212
229
  - spec/support/binding_proc.rb
213
230
  - spec/support/environment_helper.rb
214
231
  - spec/support/libvirt_context.rb
232
+ - spec/support/matchers/have_file_content.rb
215
233
  - spec/support/sharedcontext.rb
234
+ - spec/unit/action/clean_machine_folder_spec.rb
216
235
  - spec/unit/action/create_domain_spec.rb
217
236
  - spec/unit/action/create_domain_spec/default_system_storage_pool.xml
218
237
  - spec/unit/action/create_domain_spec/default_user_storage_pool.xml
238
+ - spec/unit/action/create_domain_volume_spec.rb
239
+ - spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml
240
+ - spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml
241
+ - spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml
242
+ - spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml
219
243
  - spec/unit/action/destroy_domain_spec.rb
244
+ - spec/unit/action/forward_ports_spec.rb
245
+ - spec/unit/action/halt_domain_spec.rb
246
+ - spec/unit/action/handle_box_image_spec.rb
220
247
  - spec/unit/action/set_name_of_domain_spec.rb
221
248
  - spec/unit/action/start_domain_spec.rb
222
249
  - spec/unit/action/start_domain_spec/clock_timer_rtc.xml
@@ -259,7 +286,13 @@ summary: libvirt provider for Vagrant.
259
286
  test_files:
260
287
  - spec/unit/action/start_domain_spec.rb
261
288
  - spec/unit/action/create_domain_spec.rb
289
+ - spec/unit/action/forward_ports_spec.rb
262
290
  - spec/unit/action/wait_till_up_spec.rb
291
+ - spec/unit/action/clean_machine_folder_spec.rb
292
+ - spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml
293
+ - spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml
294
+ - spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml
295
+ - spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml
263
296
  - spec/unit/action/start_domain_spec/default_added_tpm_version.xml
264
297
  - spec/unit/action/start_domain_spec/clock_timer_rtc.xml
265
298
  - spec/unit/action/start_domain_spec/default.xml
@@ -267,7 +300,10 @@ test_files:
267
300
  - spec/unit/action/destroy_domain_spec.rb
268
301
  - spec/unit/action/create_domain_spec/default_system_storage_pool.xml
269
302
  - spec/unit/action/create_domain_spec/default_user_storage_pool.xml
303
+ - spec/unit/action/handle_box_image_spec.rb
270
304
  - spec/unit/action/set_name_of_domain_spec.rb
305
+ - spec/unit/action/halt_domain_spec.rb
306
+ - spec/unit/action/create_domain_volume_spec.rb
271
307
  - spec/unit/config_spec.rb
272
308
  - spec/unit/provider_spec.rb
273
309
  - spec/unit/templates/domain_defaults.xml
@@ -277,6 +313,7 @@ test_files:
277
313
  - spec/unit/templates/tpm/version_2.0.xml
278
314
  - spec/unit/templates/domain_custom_cpu_model.xml
279
315
  - spec/support/libvirt_context.rb
316
+ - spec/support/matchers/have_file_content.rb
280
317
  - spec/support/environment_helper.rb
281
318
  - spec/support/binding_proc.rb
282
319
  - spec/support/sharedcontext.rb