vagrant-libvirt 0.1.0 → 0.4.1

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +321 -76
  3. data/lib/vagrant-libvirt/action.rb +1 -1
  4. data/lib/vagrant-libvirt/action/create_domain.rb +54 -14
  5. data/lib/vagrant-libvirt/action/create_domain_volume.rb +0 -2
  6. data/lib/vagrant-libvirt/action/create_network_interfaces.rb +1 -0
  7. data/lib/vagrant-libvirt/action/forward_ports.rb +4 -3
  8. data/lib/vagrant-libvirt/action/handle_box_image.rb +6 -3
  9. data/lib/vagrant-libvirt/action/package_domain.rb +10 -4
  10. data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +4 -3
  11. data/lib/vagrant-libvirt/action/start_domain.rb +86 -29
  12. data/lib/vagrant-libvirt/action/wait_till_up.rb +7 -27
  13. data/lib/vagrant-libvirt/cap/public_address.rb +16 -0
  14. data/lib/vagrant-libvirt/config.rb +233 -32
  15. data/lib/vagrant-libvirt/driver.rb +49 -32
  16. data/lib/vagrant-libvirt/plugin.rb +6 -0
  17. data/lib/vagrant-libvirt/provider.rb +2 -9
  18. data/lib/vagrant-libvirt/templates/domain.xml.erb +34 -5
  19. data/lib/vagrant-libvirt/templates/public_interface.xml.erb +5 -1
  20. data/lib/vagrant-libvirt/util.rb +1 -0
  21. data/lib/vagrant-libvirt/util/erb_template.rb +6 -7
  22. data/lib/vagrant-libvirt/util/ui.rb +23 -0
  23. data/lib/vagrant-libvirt/version +1 -0
  24. data/lib/vagrant-libvirt/version.rb +72 -1
  25. data/spec/spec_helper.rb +28 -2
  26. data/spec/support/binding_proc.rb +24 -0
  27. data/spec/support/libvirt_context.rb +3 -1
  28. data/spec/support/sharedcontext.rb +7 -3
  29. data/spec/unit/action/create_domain_spec.rb +160 -0
  30. data/spec/unit/action/create_domain_spec/default_system_storage_pool.xml +17 -0
  31. data/spec/unit/action/create_domain_spec/default_user_storage_pool.xml +17 -0
  32. data/spec/unit/action/destroy_domain_spec.rb +2 -2
  33. data/spec/unit/action/set_name_of_domain_spec.rb +2 -2
  34. data/spec/unit/action/start_domain_spec.rb +231 -0
  35. data/spec/unit/action/start_domain_spec/clock_timer_rtc.xml +50 -0
  36. data/spec/unit/action/start_domain_spec/default.xml +48 -0
  37. data/spec/unit/action/start_domain_spec/default_added_tpm_path.xml +48 -0
  38. data/spec/unit/action/start_domain_spec/default_added_tpm_version.xml +48 -0
  39. data/spec/unit/action/wait_till_up_spec.rb +32 -9
  40. data/spec/unit/config_spec.rb +438 -0
  41. data/spec/unit/provider_spec.rb +11 -0
  42. data/spec/unit/templates/domain_all_settings.xml +8 -3
  43. data/spec/unit/templates/domain_custom_cpu_model.xml +4 -1
  44. data/spec/unit/templates/domain_defaults.xml +4 -1
  45. data/spec/unit/templates/domain_spec.rb +82 -2
  46. data/spec/unit/templates/tpm/version_1.2.xml +54 -0
  47. data/spec/unit/templates/tpm/version_2.0.xml +53 -0
  48. metadata +62 -6
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'support/sharedcontext'
3
+
4
+ describe 'VagrantPlugins::ProviderLibvirt::Provider' do
5
+ require 'vagrant-libvirt/provider'
6
+
7
+ include_context 'unit'
8
+
9
+ describe '#ssh_info' do
10
+ end
11
+ end
@@ -1,5 +1,7 @@
1
1
  <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
2
2
  <name></name>
3
+ <title>title</title>
4
+ <description>description</description>
3
5
  <uuid></uuid>
4
6
  <memory></memory>
5
7
  <vcpu cpuset='1-4,^3,6'>1</vcpu>
@@ -34,11 +36,14 @@
34
36
  <BBB state='on' />
35
37
  </hyperv>
36
38
  </features>
37
- <clock offset='utc'/>
39
+ <clock offset='variable'>
40
+ <timer name='t1'/>
41
+ <timer name='t2' track='b' tickpolicy='c' frequency='d' mode='e' present='yes'/>
42
+ </clock>
38
43
  <devices>
39
44
  <emulator>/usr/bin/kvm-spice</emulator>
40
45
  <disk type='file' device='disk'>
41
- <driver name='qemu' type='qcow2' cache='unsafe'/>
46
+ <driver name='qemu' type='qcow2' cache='unsafe' io='threads' copy_on_read='on' discard='unmap' detect_zeroes='on'/>
42
47
  <source file='/var/lib/libvirt/images/test.qcow2'/>
43
48
  <target dev='vda' bus='ide'/>
44
49
  </disk>
@@ -48,7 +53,7 @@
48
53
  <target dev='vdb' bus='virtio'/>
49
54
  </disk>
50
55
  <disk type='file' device='disk'>
51
- <driver name='qemu' type='qcow2' cache='default'/>
56
+ <driver name='qemu' type='qcow2' cache='default' io='threads' copy_on_read='on' discard='unmap' detect_zeroes='on'/>
52
57
  <source file='/var/lib/libvirt/images/test-disk2.qcow2'/>
53
58
  <target dev='vdc' bus='virtio'/>
54
59
  </disk>
@@ -1,5 +1,7 @@
1
1
  <domain type='' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
2
2
  <name></name>
3
+ <title></title>
4
+ <description></description>
3
5
  <uuid></uuid>
4
6
  <memory></memory>
5
7
  <vcpu>1</vcpu>
@@ -21,7 +23,8 @@
21
23
  <apic/>
22
24
  <pae/>
23
25
  </features>
24
- <clock offset='utc'/>
26
+ <clock offset='utc'>
27
+ </clock>
25
28
  <devices>
26
29
 
27
30
 
@@ -1,5 +1,7 @@
1
1
  <domain type='' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
2
2
  <name></name>
3
+ <title></title>
4
+ <description></description>
3
5
  <uuid></uuid>
4
6
  <memory></memory>
5
7
  <vcpu>1</vcpu>
@@ -21,7 +23,8 @@
21
23
  <apic/>
22
24
  <pae/>
23
25
  </features>
24
- <clock offset='utc'/>
26
+ <clock offset='utc'>
27
+ </clock>
25
28
  <devices>
26
29
 
27
30
 
@@ -27,10 +27,15 @@ describe 'templates/domain' do
27
27
 
28
28
  context 'when all settings enabled' do
29
29
  before do
30
+ domain.title = 'title'
31
+ domain.description = 'description'
30
32
  domain.instance_variable_set('@domain_type', 'kvm')
31
33
  domain.cpu_mode = 'custom'
32
34
  domain.cpu_feature(name: 'AAA', policy: 'required')
33
35
  domain.hyperv_feature(name: 'BBB', state: 'on')
36
+ domain.clock_offset = 'variable'
37
+ domain.clock_timer(name: 't1')
38
+ domain.clock_timer(name: 't2', track: 'b', tickpolicy: 'c', frequency: 'd', mode: 'e', present: 'yes')
34
39
  domain.cputopology(sockets: '1', cores: '3', threads: '2')
35
40
  domain.machine_type = 'pc-compatible'
36
41
  domain.machine_arch = 'x86_64'
@@ -40,11 +45,12 @@ describe 'templates/domain' do
40
45
  domain.boot('hd')
41
46
  domain.emulator_path = '/usr/bin/kvm-spice'
42
47
  domain.instance_variable_set('@domain_volume_path', '/var/lib/libvirt/images/test.qcow2')
43
- domain.instance_variable_set('@domain_volume_cache', 'unsafe')
48
+ domain.instance_variable_set('@domain_volume_cache', 'deprecated')
44
49
  domain.disk_bus = 'ide'
45
50
  domain.disk_device = 'vda'
51
+ domain.disk_driver(:cache => 'unsafe', :io => 'threads', :copy_on_read => 'on', :discard => 'unmap', :detect_zeroes => 'on')
46
52
  domain.storage(:file, path: 'test-disk1.qcow2')
47
- domain.storage(:file, path: 'test-disk2.qcow2')
53
+ domain.storage(:file, path: 'test-disk2.qcow2', io: 'threads', copy_on_read: 'on', discard: 'unmap', detect_zeroes: 'on')
48
54
  domain.disks.each do |disk|
49
55
  disk[:absolute_path] = '/var/lib/libvirt/images/' + disk[:path]
50
56
  end
@@ -103,4 +109,78 @@ describe 'templates/domain' do
103
109
  expect(domain.to_xml('domain')).to eq xml_expected
104
110
  end
105
111
  end
112
+
113
+ context 'when tpm 2.0 device is specified' do
114
+ before do
115
+ domain.tpm_version = '2.0'
116
+ domain.tpm_type = 'emulator'
117
+ domain.tpm_model = 'tpm-crb'
118
+ end
119
+ let(:test_file) { 'tpm/version_2.0.xml' }
120
+ it 'renders template' do
121
+ domain.finalize!
122
+ expect(domain.to_xml('domain')).to eq xml_expected
123
+ end
124
+ end
125
+
126
+ context 'when tpm 1.2 device is implicitly used' do
127
+ before do
128
+ domain.tpm_path = '/dev/tpm0'
129
+ end
130
+ let(:test_file) { 'tpm/version_1.2.xml' }
131
+ it 'renders template' do
132
+ domain.finalize!
133
+ expect(domain.to_xml('domain')).to eq xml_expected
134
+ end
135
+ end
136
+
137
+ context 'memballoon' do
138
+ context 'default' do
139
+ it 'renders without specifying the xml tag' do
140
+ domain.finalize!
141
+
142
+ expect(domain.to_xml('domain')).to_not match(/memballoon/)
143
+ end
144
+ end
145
+
146
+ context 'memballon enabled' do
147
+ before do
148
+ domain.memballoon_enabled = true
149
+ end
150
+
151
+ it 'renders with memballon element' do
152
+ domain.finalize!
153
+
154
+ expect(domain.to_xml('domain')).to match(/<memballoon model='virtio'>/)
155
+ expect(domain.to_xml('domain')).to match(/<address type='pci' domain='0x0000' bus='0x00' slot='0x0f' function='0x0'\/>/)
156
+ end
157
+
158
+ context 'all settings specified' do
159
+ before do
160
+ domain.memballoon_model = "virtio-non-transitional"
161
+ domain.memballoon_pci_bus = "0x01"
162
+ domain.memballoon_pci_slot = "0x05"
163
+ end
164
+
165
+ it 'renders with specified values' do
166
+ domain.finalize!
167
+
168
+ expect(domain.to_xml('domain')).to match(/<memballoon model='virtio-non-transitional'>/)
169
+ expect(domain.to_xml('domain')).to match(/<address type='pci' domain='0x0000' bus='0x01' slot='0x05' function='0x0'\/>/)
170
+ end
171
+ end
172
+ end
173
+
174
+ context 'memballon disabled' do
175
+ before do
176
+ domain.memballoon_enabled = false
177
+ end
178
+
179
+ it 'renders the memballoon element with model none' do
180
+ domain.finalize!
181
+
182
+ expect(domain.to_xml('domain')).to match(/<memballoon model='none'\/>/)
183
+ end
184
+ end
185
+ end
106
186
  end
@@ -0,0 +1,54 @@
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
+
9
+
10
+ <cpu mode='host-model'>
11
+ <model fallback='allow'></model>
12
+ </cpu>
13
+
14
+
15
+ <os>
16
+ <type>hvm</type>
17
+ <kernel></kernel>
18
+ <initrd></initrd>
19
+ <cmdline></cmdline>
20
+ </os>
21
+ <features>
22
+ <acpi/>
23
+ <apic/>
24
+ <pae/>
25
+ </features>
26
+ <clock offset='utc'>
27
+ </clock>
28
+ <devices>
29
+
30
+
31
+ <serial type='pty'>
32
+ <target port='0'/>
33
+ </serial>
34
+ <console type='pty'>
35
+ <target port='0'/>
36
+ </console>
37
+
38
+
39
+ <input type='mouse' bus='ps2'/>
40
+
41
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us' />
42
+ <video>
43
+ <model type='cirrus' vram='9216' heads='1'/>
44
+ </video>
45
+
46
+
47
+ <tpm model='tpm-tis'>
48
+ <backend type='passthrough'>
49
+ <device path='/dev/tpm0'/>
50
+ </backend>
51
+ </tpm>
52
+ </devices>
53
+
54
+ </domain>
@@ -0,0 +1,53 @@
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
+
9
+
10
+ <cpu mode='host-model'>
11
+ <model fallback='allow'></model>
12
+ </cpu>
13
+
14
+
15
+ <os>
16
+ <type>hvm</type>
17
+ <kernel></kernel>
18
+ <initrd></initrd>
19
+ <cmdline></cmdline>
20
+ </os>
21
+ <features>
22
+ <acpi/>
23
+ <apic/>
24
+ <pae/>
25
+ </features>
26
+ <clock offset='utc'>
27
+ </clock>
28
+ <devices>
29
+
30
+
31
+ <serial type='pty'>
32
+ <target port='0'/>
33
+ </serial>
34
+ <console type='pty'>
35
+ <target port='0'/>
36
+ </console>
37
+
38
+
39
+ <input type='mouse' bus='ps2'/>
40
+
41
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us' />
42
+ <video>
43
+ <model type='cirrus' vram='9216' heads='1'/>
44
+ </video>
45
+
46
+
47
+ <tpm model='tpm-crb'>
48
+ <backend type='emulator' version='2.0'>
49
+ </backend>
50
+ </tpm>
51
+ </devices>
52
+
53
+ </domain>
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-libvirt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Stanek
8
8
  - Dima Vasilets
9
9
  - Brian Pitts
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-05-10 00:00:00.000000000 Z
13
+ date: 2021-04-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec-core
@@ -54,6 +54,34 @@ dependencies:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
56
  version: 3.5.0
57
+ - !ruby/object:Gem::Dependency
58
+ name: simplecov
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: simplecov-lcov
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
57
85
  - !ruby/object:Gem::Dependency
58
86
  name: fog-libvirt
59
87
  requirement: !ruby/object:Gem::Requirement
@@ -157,6 +185,7 @@ files:
157
185
  - lib/vagrant-libvirt/action/wait_till_up.rb
158
186
  - lib/vagrant-libvirt/cap/mount_p9.rb
159
187
  - lib/vagrant-libvirt/cap/nic_mac_addresses.rb
188
+ - lib/vagrant-libvirt/cap/public_address.rb
160
189
  - lib/vagrant-libvirt/cap/synced_folder.rb
161
190
  - lib/vagrant-libvirt/config.rb
162
191
  - lib/vagrant-libvirt/driver.rb
@@ -175,25 +204,39 @@ files:
175
204
  - lib/vagrant-libvirt/util/nfs.rb
176
205
  - lib/vagrant-libvirt/util/storage_util.rb
177
206
  - lib/vagrant-libvirt/util/timer.rb
207
+ - lib/vagrant-libvirt/util/ui.rb
208
+ - lib/vagrant-libvirt/version
178
209
  - lib/vagrant-libvirt/version.rb
179
210
  - locales/en.yml
180
211
  - spec/spec_helper.rb
212
+ - spec/support/binding_proc.rb
181
213
  - spec/support/environment_helper.rb
182
214
  - spec/support/libvirt_context.rb
183
215
  - spec/support/sharedcontext.rb
216
+ - spec/unit/action/create_domain_spec.rb
217
+ - spec/unit/action/create_domain_spec/default_system_storage_pool.xml
218
+ - spec/unit/action/create_domain_spec/default_user_storage_pool.xml
184
219
  - spec/unit/action/destroy_domain_spec.rb
185
220
  - spec/unit/action/set_name_of_domain_spec.rb
221
+ - spec/unit/action/start_domain_spec.rb
222
+ - spec/unit/action/start_domain_spec/clock_timer_rtc.xml
223
+ - spec/unit/action/start_domain_spec/default.xml
224
+ - spec/unit/action/start_domain_spec/default_added_tpm_path.xml
225
+ - spec/unit/action/start_domain_spec/default_added_tpm_version.xml
186
226
  - spec/unit/action/wait_till_up_spec.rb
187
227
  - spec/unit/config_spec.rb
228
+ - spec/unit/provider_spec.rb
188
229
  - spec/unit/templates/domain_all_settings.xml
189
230
  - spec/unit/templates/domain_custom_cpu_model.xml
190
231
  - spec/unit/templates/domain_defaults.xml
191
232
  - spec/unit/templates/domain_spec.rb
233
+ - spec/unit/templates/tpm/version_1.2.xml
234
+ - spec/unit/templates/tpm/version_2.0.xml
192
235
  homepage: https://github.com/vagrant-libvirt/vagrant-libvirt
193
236
  licenses:
194
237
  - MIT
195
238
  metadata: {}
196
- post_install_message:
239
+ post_install_message:
197
240
  rdoc_options: []
198
241
  require_paths:
199
242
  - lib
@@ -208,20 +251,33 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
251
  - !ruby/object:Gem::Version
209
252
  version: '0'
210
253
  requirements: []
211
- rubygems_version: 3.0.3
212
- signing_key:
254
+ rubyforge_project:
255
+ rubygems_version: 2.7.11
256
+ signing_key:
213
257
  specification_version: 4
214
258
  summary: libvirt provider for Vagrant.
215
259
  test_files:
260
+ - spec/unit/action/start_domain_spec.rb
261
+ - spec/unit/action/create_domain_spec.rb
216
262
  - spec/unit/action/wait_till_up_spec.rb
263
+ - spec/unit/action/start_domain_spec/default_added_tpm_version.xml
264
+ - spec/unit/action/start_domain_spec/clock_timer_rtc.xml
265
+ - spec/unit/action/start_domain_spec/default.xml
266
+ - spec/unit/action/start_domain_spec/default_added_tpm_path.xml
217
267
  - spec/unit/action/destroy_domain_spec.rb
268
+ - spec/unit/action/create_domain_spec/default_system_storage_pool.xml
269
+ - spec/unit/action/create_domain_spec/default_user_storage_pool.xml
218
270
  - spec/unit/action/set_name_of_domain_spec.rb
219
271
  - spec/unit/config_spec.rb
272
+ - spec/unit/provider_spec.rb
220
273
  - spec/unit/templates/domain_defaults.xml
221
274
  - spec/unit/templates/domain_all_settings.xml
222
275
  - spec/unit/templates/domain_spec.rb
276
+ - spec/unit/templates/tpm/version_1.2.xml
277
+ - spec/unit/templates/tpm/version_2.0.xml
223
278
  - spec/unit/templates/domain_custom_cpu_model.xml
224
279
  - spec/support/libvirt_context.rb
225
280
  - spec/support/environment_helper.rb
281
+ - spec/support/binding_proc.rb
226
282
  - spec/support/sharedcontext.rb
227
283
  - spec/spec_helper.rb