vagrant-libvirt 0.11.2 → 0.12.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/lib/vagrant-libvirt/action/create_domain.rb +15 -1
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +1 -0
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +7 -3
- data/lib/vagrant-libvirt/action/create_networks.rb +1 -1
- data/lib/vagrant-libvirt/action/destroy_domain_confirm.rb +22 -0
- data/lib/vagrant-libvirt/action/forward_ports.rb +1 -1
- data/lib/vagrant-libvirt/action/handle_box_image.rb +6 -3
- data/lib/vagrant-libvirt/action/start_domain.rb +38 -9
- data/lib/vagrant-libvirt/action.rb +0 -2
- data/lib/vagrant-libvirt/config.rb +75 -28
- data/lib/vagrant-libvirt/templates/domain.xml.erb +25 -14
- data/lib/vagrant-libvirt/templates/public_interface.xml.erb +22 -17
- data/lib/vagrant-libvirt/util/network_util.rb +25 -22
- data/lib/vagrant-libvirt/version +1 -1
- data/spec/support/libvirt_acceptance_context.rb +1 -1
- data/spec/support/matchers/have_file_content.rb +1 -1
- data/spec/support/unit_context.rb +0 -3
- data/spec/unit/action/clean_machine_folder_spec.rb +3 -3
- data/spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml +1 -0
- data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml +1 -0
- data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml +1 -0
- data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml +1 -0
- data/spec/unit/action/create_network_interfaces.rb +305 -0
- data/spec/unit/action/handle_box_image_spec.rb +9 -2
- data/spec/unit/action/start_domain_spec.rb +42 -0
- data/spec/unit/action_spec.rb +62 -1
- data/spec/unit/cap/mount_9p_spec.rb +4 -0
- data/spec/unit/config_spec.rb +39 -10
- data/spec/unit/driver_spec.rb +29 -18
- data/spec/unit/templates/domain_all_settings.xml +2 -2
- data/spec/unit/templates/domain_spec.rb +2 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7c040a1d251767da60c78665550646f187542bbf7b9997cc79fad57912496026
|
|
4
|
+
data.tar.gz: da241c3927605330f056e1b235910f35c9387b130fe645ba42418b388b34f08d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0478c2e07037e6ca618f17d4965bed901227d48cc7eed448afb099d079e807450263b7ded71cd7a26dfaa83676e25cea890623b7b678c2c5b798df10895366a8'
|
|
7
|
+
data.tar.gz: bd18eb62fd9e0cd134511cdf642697272a16ae85fa882e9bcdfb9fea157878b2fa918e71fd0c9fa418a104e846211892450ad097965f588f4590495fdec00d3f
|
|
@@ -36,7 +36,11 @@ module VagrantPlugins
|
|
|
36
36
|
@nodeset = config.nodeset
|
|
37
37
|
@features = config.features
|
|
38
38
|
@features_hyperv = config.features_hyperv
|
|
39
|
+
@clock_absolute = config.clock_absolute
|
|
40
|
+
@clock_adjustment = config.clock_adjustment
|
|
41
|
+
@clock_basis = config.clock_basis
|
|
39
42
|
@clock_offset = config.clock_offset
|
|
43
|
+
@clock_timezone = config.clock_timezone
|
|
40
44
|
@clock_timers = config.clock_timers
|
|
41
45
|
@launchsecurity_data = config.launchsecurity_data
|
|
42
46
|
@shares = config.shares
|
|
@@ -198,6 +202,8 @@ module VagrantPlugins
|
|
|
198
202
|
dir = File.dirname(serial[:source][:path])
|
|
199
203
|
begin
|
|
200
204
|
FileUtils.mkdir_p(dir)
|
|
205
|
+
FileUtils.touch(serial[:source][:path])
|
|
206
|
+
File.truncate(serial[:source][:path], 0) unless serial[:source].fetch(:append, false)
|
|
201
207
|
rescue ::Errno::EACCES
|
|
202
208
|
raise Errors::SerialCannotCreatePathError,
|
|
203
209
|
path: dir
|
|
@@ -234,7 +240,15 @@ module VagrantPlugins
|
|
|
234
240
|
env[:ui].info(" -- Feature (HyperV): name=#{feature[:name]}, state=#{feature[:state]}")
|
|
235
241
|
end
|
|
236
242
|
end
|
|
237
|
-
|
|
243
|
+
if not @clock_absolute.nil?
|
|
244
|
+
env[:ui].info(" -- Clock absolute: #{@clock_absolute}")
|
|
245
|
+
elsif not @clock_adjustment.nil?
|
|
246
|
+
env[:ui].info(" -- Clock adjustment: #{@clock_adjustment}")
|
|
247
|
+
elsif not @clock_timezone.nil?
|
|
248
|
+
env[:ui].info(" -- Clock timezone: #{@clock_timezone}")
|
|
249
|
+
else
|
|
250
|
+
env[:ui].info(" -- Clock offset: #{@clock_offset}")
|
|
251
|
+
end
|
|
238
252
|
@clock_timers.each do |timer|
|
|
239
253
|
env[:ui].info(" -- Clock timer: #{timer.map { |k,v| "#{k}=#{v}"}.join(', ')}")
|
|
240
254
|
end
|
|
@@ -4,6 +4,9 @@ require 'log4r'
|
|
|
4
4
|
require 'vagrant/util/network_ip'
|
|
5
5
|
require 'vagrant/util/scoped_hash_override'
|
|
6
6
|
|
|
7
|
+
require 'vagrant-libvirt/util/erb_template'
|
|
8
|
+
require 'vagrant-libvirt/util/network_util'
|
|
9
|
+
|
|
7
10
|
module VagrantPlugins
|
|
8
11
|
module ProviderLibvirt
|
|
9
12
|
module Action
|
|
@@ -40,7 +43,7 @@ module VagrantPlugins
|
|
|
40
43
|
|
|
41
44
|
# Vagrant gives you adapter 0 by default
|
|
42
45
|
# Assign interfaces to slots.
|
|
43
|
-
configured_networks(env, @logger).each do |options|
|
|
46
|
+
configured_networks(env[:machine], @logger).each do |options|
|
|
44
47
|
# don't need to create interface for this type
|
|
45
48
|
next if options[:iface_type] == :forwarded_port
|
|
46
49
|
|
|
@@ -96,6 +99,7 @@ module VagrantPlugins
|
|
|
96
99
|
@driver_iommu = iface_configuration.fetch(:driver_iommu, false )
|
|
97
100
|
@driver_name = iface_configuration.fetch(:driver_name, false)
|
|
98
101
|
@driver_queues = iface_configuration.fetch(:driver_queues, false)
|
|
102
|
+
@device_name = iface_configuration.fetch(:iface_name, nil)
|
|
99
103
|
@portgroup = iface_configuration.fetch(:portgroup, nil)
|
|
100
104
|
@network_name = iface_configuration.fetch(:network_name, @network_name)
|
|
101
105
|
template_name = 'public_interface'
|
|
@@ -146,7 +150,7 @@ module VagrantPlugins
|
|
|
146
150
|
# FIXME: all options for network driver should be hash from Vagrantfile
|
|
147
151
|
driver_options = {}
|
|
148
152
|
driver_options[:name] = @driver_name if @driver_name
|
|
149
|
-
driver_options[:iommu] = @driver_iommu ? "on" : "off" if @
|
|
153
|
+
driver_options[:iommu] = @driver_iommu ? "on" : "off" if @model_type == 'virtio'
|
|
150
154
|
driver_options[:queues] = @driver_queues if @driver_queues
|
|
151
155
|
|
|
152
156
|
@udp_tunnel ||= {}
|
|
@@ -169,7 +173,7 @@ module VagrantPlugins
|
|
|
169
173
|
@logger.debug {
|
|
170
174
|
"Attaching Network Device with XML:\n#{xml}"
|
|
171
175
|
}
|
|
172
|
-
|
|
176
|
+
env[:machine].provider.driver.attach_device(xml)
|
|
173
177
|
rescue => e
|
|
174
178
|
raise Errors::AttachDeviceError,
|
|
175
179
|
error_message: e.message
|
|
@@ -47,7 +47,7 @@ module VagrantPlugins
|
|
|
47
47
|
@@lock.synchronize do
|
|
48
48
|
# Iterate over networks If some network is not
|
|
49
49
|
# available, create it if possible. Otherwise raise an error.
|
|
50
|
-
configured_networks(env, @logger).each do |options|
|
|
50
|
+
configured_networks(env[:machine], @logger).each do |options|
|
|
51
51
|
# Only need to create private networks
|
|
52
52
|
next if options[:iface_type] != :private_network ||
|
|
53
53
|
options.fetch(:tunnel_type, nil)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
require "vagrant/action/builtin/confirm"
|
|
3
|
+
|
|
4
|
+
module VagrantPlugins
|
|
5
|
+
module VagrantLibvirt
|
|
6
|
+
module Action
|
|
7
|
+
class DestroyDomainConfirm < Vagrant::Action::Builtin::Confirm
|
|
8
|
+
def initialize(app, env)
|
|
9
|
+
force_key = :force_confirm_destroy
|
|
10
|
+
message = I18n.t("vagrant_libvirt.destroy_domain.confirmation",
|
|
11
|
+
name: env[:machine].name)
|
|
12
|
+
|
|
13
|
+
super(app, env, message, force_key, allowed: ["y", "n", "Y", "N"])
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def call(env)
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -43,6 +43,7 @@ module VagrantPlugins
|
|
|
43
43
|
:name => HandleBoxImage.get_volume_name(env[:machine].box, 'box', image_path, env[:ui]),
|
|
44
44
|
:virtual_size => HandleBoxImage.get_virtual_size(env),
|
|
45
45
|
:format => box_format,
|
|
46
|
+
:compat => "1.1",
|
|
46
47
|
}]
|
|
47
48
|
else
|
|
48
49
|
# Handle box v2 format
|
|
@@ -57,7 +58,7 @@ module VagrantPlugins
|
|
|
57
58
|
raise Errors::BoxFormatMissingAttribute, attribute: "disks[#{i}]['path']" if disks[i]['path'].nil?
|
|
58
59
|
|
|
59
60
|
image_path = HandleBoxImage.get_box_image_path(env[:machine].box, disks[i]['path'])
|
|
60
|
-
format, virtual_size = HandleBoxImage.get_box_disk_settings(image_path)
|
|
61
|
+
format, virtual_size, compat = HandleBoxImage.get_box_disk_settings(image_path)
|
|
61
62
|
volume_name = HandleBoxImage.get_volume_name(
|
|
62
63
|
env[:machine].box,
|
|
63
64
|
disks[i].fetch('name', disks[i]['path'].sub(/#{File.extname(disks[i]['path'])}$/, '')),
|
|
@@ -76,7 +77,8 @@ module VagrantPlugins
|
|
|
76
77
|
:path => image_path,
|
|
77
78
|
:name => volume_name,
|
|
78
79
|
:virtual_size => virtual_size,
|
|
79
|
-
:format => HandleBoxImage.verify_box_format(format)
|
|
80
|
+
:format => HandleBoxImage.verify_box_format(format),
|
|
81
|
+
:compat => compat,
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
end
|
|
@@ -180,8 +182,9 @@ module VagrantPlugins
|
|
|
180
182
|
image_info = JSON.parse(stdout)
|
|
181
183
|
format = image_info['format']
|
|
182
184
|
virtual_size = ByteNumber.new(image_info['virtual-size'])
|
|
185
|
+
compat = image_info.fetch("format-specific", {}).fetch("data", {}).fetch("compat", "0.10")
|
|
183
186
|
|
|
184
|
-
return format, virtual_size
|
|
187
|
+
return format, virtual_size, compat
|
|
185
188
|
end
|
|
186
189
|
|
|
187
190
|
def send_box_image(env, config, box_image_file, box_volume)
|
|
@@ -166,12 +166,29 @@ module VagrantPlugins
|
|
|
166
166
|
xml_descr.delete_element('/domain/cpu')
|
|
167
167
|
end
|
|
168
168
|
|
|
169
|
-
# Clock
|
|
169
|
+
# Clock - can change in complicated ways, so just build a new clock and compare
|
|
170
|
+
newclock = REXML::Element.new('newclock')
|
|
171
|
+
if not config.clock_absolute.nil?
|
|
172
|
+
newclock.add_attribute('offset', 'absolute')
|
|
173
|
+
newclock.add_attribute('start', config.clock_absolute)
|
|
174
|
+
elsif not config.clock_adjustment.nil?
|
|
175
|
+
newclock.add_attribute('offset', 'variable')
|
|
176
|
+
newclock.add_attribute('basis', config.clock_basis)
|
|
177
|
+
newclock.add_attribute('adjustment', config.clock_adjustment)
|
|
178
|
+
elsif not config.clock_timezone.nil?
|
|
179
|
+
newclock.add_attribute('offset', 'timezone')
|
|
180
|
+
newclock.add_attribute('timezone', config.clock_timezone)
|
|
181
|
+
else
|
|
182
|
+
newclock.add_attribute('offset', config.clock_offset)
|
|
183
|
+
end
|
|
170
184
|
clock = REXML::XPath.first(xml_descr, '/domain/clock')
|
|
171
|
-
if clock.attributes
|
|
172
|
-
@logger.debug "clock
|
|
185
|
+
if clock.attributes != newclock.attributes
|
|
186
|
+
@logger.debug "clock definition changed"
|
|
173
187
|
descr_changed = true
|
|
174
|
-
clock.attributes
|
|
188
|
+
clock.attributes.clear
|
|
189
|
+
newclock.attributes.each do |attr, value|
|
|
190
|
+
clock.add_attribute(attr, value)
|
|
191
|
+
end
|
|
175
192
|
end
|
|
176
193
|
|
|
177
194
|
# clock timers - because timers can be added/removed, just rebuild and then compare
|
|
@@ -272,13 +289,25 @@ module VagrantPlugins
|
|
|
272
289
|
graphics.attributes['listen'] = config.graphics_ip
|
|
273
290
|
graphics.delete_element('//listen')
|
|
274
291
|
end
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
292
|
+
unless config.graphics_port.nil? or config.graphics_port == -1
|
|
293
|
+
if graphics.attributes['autoport'] != 'no'
|
|
294
|
+
descr_changed = true
|
|
295
|
+
graphics.attributes['autoport'] = 'no'
|
|
296
|
+
end
|
|
297
|
+
if graphics.attributes['port'] != config.graphics_port
|
|
298
|
+
descr_changed = true
|
|
280
299
|
graphics.attributes['port'] = config.graphics_port
|
|
281
300
|
end
|
|
301
|
+
else
|
|
302
|
+
if graphics.attributes['autoport'] != config.graphics_autoport
|
|
303
|
+
descr_changed = true
|
|
304
|
+
graphics.attributes['autoport'] = config.graphics_autoport
|
|
305
|
+
if config.graphics_autoport == 'no'
|
|
306
|
+
graphics.attributes['port'] = config.graphics_port
|
|
307
|
+
else
|
|
308
|
+
graphics.attributes['port'] = '-1'
|
|
309
|
+
end
|
|
310
|
+
end
|
|
282
311
|
end
|
|
283
312
|
if graphics.attributes['websocket'] != config.graphics_websocket.to_s
|
|
284
313
|
descr_changed = true
|
|
@@ -128,9 +128,7 @@ module VagrantPlugins
|
|
|
128
128
|
private_class_method def self.action_start
|
|
129
129
|
Vagrant::Action::Builder.new.tap do |b|
|
|
130
130
|
b.use Call, IsRunning do |env, b2|
|
|
131
|
-
# If the VM is running, run the necessary provisioners
|
|
132
131
|
if env[:result]
|
|
133
|
-
b2.use action_provision
|
|
134
132
|
next
|
|
135
133
|
end
|
|
136
134
|
|
|
@@ -7,11 +7,13 @@ require 'vagrant/action/builtin/mixin_synced_folders'
|
|
|
7
7
|
|
|
8
8
|
require 'vagrant-libvirt/errors'
|
|
9
9
|
require 'vagrant-libvirt/util/resolvers'
|
|
10
|
+
require 'vagrant-libvirt/util/network_util'
|
|
10
11
|
|
|
11
12
|
module VagrantPlugins
|
|
12
13
|
module ProviderLibvirt
|
|
13
14
|
class Config < Vagrant.plugin('2', :config)
|
|
14
15
|
include Vagrant::Action::Builtin::MixinSyncedFolders
|
|
16
|
+
include VagrantPlugins::ProviderLibvirt::Util::NetworkUtil
|
|
15
17
|
|
|
16
18
|
# manually specify URI
|
|
17
19
|
# will supersede most other options if provided
|
|
@@ -68,6 +70,7 @@ module VagrantPlugins
|
|
|
68
70
|
attr_accessor :management_network_mtu
|
|
69
71
|
attr_accessor :management_network_keep
|
|
70
72
|
attr_accessor :management_network_driver_iommu
|
|
73
|
+
attr_accessor :management_network_model_type
|
|
71
74
|
|
|
72
75
|
# System connection information
|
|
73
76
|
attr_accessor :system_uri
|
|
@@ -95,7 +98,11 @@ module VagrantPlugins
|
|
|
95
98
|
attr_accessor :shares
|
|
96
99
|
attr_accessor :features
|
|
97
100
|
attr_accessor :features_hyperv
|
|
101
|
+
attr_accessor :clock_absolute
|
|
102
|
+
attr_accessor :clock_adjustment
|
|
103
|
+
attr_accessor :clock_basis
|
|
98
104
|
attr_accessor :clock_offset
|
|
105
|
+
attr_accessor :clock_timezone
|
|
99
106
|
attr_accessor :clock_timers
|
|
100
107
|
attr_accessor :launchsecurity_data
|
|
101
108
|
attr_accessor :numa_nodes
|
|
@@ -222,6 +229,8 @@ module VagrantPlugins
|
|
|
222
229
|
]
|
|
223
230
|
|
|
224
231
|
def initialize
|
|
232
|
+
@logger = Log4r::Logger.new("vagrant_libvirt::config")
|
|
233
|
+
|
|
225
234
|
@uri = UNSET_VALUE
|
|
226
235
|
@driver = UNSET_VALUE
|
|
227
236
|
@host = UNSET_VALUE
|
|
@@ -249,6 +258,7 @@ module VagrantPlugins
|
|
|
249
258
|
@management_network_mtu = UNSET_VALUE
|
|
250
259
|
@management_network_keep = UNSET_VALUE
|
|
251
260
|
@management_network_driver_iommu = UNSET_VALUE
|
|
261
|
+
@management_network_model_type = UNSET_VALUE
|
|
252
262
|
|
|
253
263
|
# System connection information
|
|
254
264
|
@system_uri = UNSET_VALUE
|
|
@@ -272,7 +282,11 @@ module VagrantPlugins
|
|
|
272
282
|
@shares = UNSET_VALUE
|
|
273
283
|
@features = UNSET_VALUE
|
|
274
284
|
@features_hyperv = UNSET_VALUE
|
|
285
|
+
@clock_absolute = UNSET_VALUE
|
|
286
|
+
@clock_adjustment = UNSET_VALUE
|
|
287
|
+
@clock_basis = UNSET_VALUE
|
|
275
288
|
@clock_offset = UNSET_VALUE
|
|
289
|
+
@clock_timezone = UNSET_VALUE
|
|
276
290
|
@clock_timers = []
|
|
277
291
|
@launchsecurity_data = UNSET_VALUE
|
|
278
292
|
@numa_nodes = UNSET_VALUE
|
|
@@ -720,7 +734,7 @@ module VagrantPlugins
|
|
|
720
734
|
|
|
721
735
|
# Disk driver options for primary disk
|
|
722
736
|
def disk_driver(options = {})
|
|
723
|
-
supported_opts = [:cache, :io, :copy_on_read, :discard, :detect_zeroes]
|
|
737
|
+
supported_opts = [:cache, :io, :copy_on_read, :discard, :detect_zeroes, :type]
|
|
724
738
|
@disk_driver_opts = options.select { |k,_| supported_opts.include? k }
|
|
725
739
|
end
|
|
726
740
|
|
|
@@ -959,6 +973,7 @@ module VagrantPlugins
|
|
|
959
973
|
@management_network_mtu = nil if @management_network_mtu == UNSET_VALUE
|
|
960
974
|
@management_network_keep = false if @management_network_keep == UNSET_VALUE
|
|
961
975
|
@management_network_driver_iommu = false if @management_network_driver_iommu == UNSET_VALUE
|
|
976
|
+
@management_network_model_type = 'virtio' if @management_network_model_type == UNSET_VALUE
|
|
962
977
|
|
|
963
978
|
# Domain specific settings.
|
|
964
979
|
@title = '' if @title == UNSET_VALUE
|
|
@@ -995,7 +1010,11 @@ module VagrantPlugins
|
|
|
995
1010
|
@shares = nil if @shares == UNSET_VALUE
|
|
996
1011
|
@features = ['acpi','apic','pae'] if @features == UNSET_VALUE
|
|
997
1012
|
@features_hyperv = [] if @features_hyperv == UNSET_VALUE
|
|
1013
|
+
@clock_absolute = nil if @clock_absolute == UNSET_VALUE
|
|
1014
|
+
@clock_adjustment = nil if @clock_adjustment == UNSET_VALUE
|
|
1015
|
+
@clock_basis = 'utc' if @clock_basis == UNSET_VALUE
|
|
998
1016
|
@clock_offset = 'utc' if @clock_offset == UNSET_VALUE
|
|
1017
|
+
@clock_timezone = nil if @clock_timezone == UNSET_VALUE
|
|
999
1018
|
@clock_timers = [] if @clock_timers == UNSET_VALUE
|
|
1000
1019
|
@launchsecurity_data = nil if @launchsecurity_data == UNSET_VALUE
|
|
1001
1020
|
@numa_nodes = @numa_nodes == UNSET_VALUE ? nil : _generate_numa
|
|
@@ -1206,27 +1225,7 @@ module VagrantPlugins
|
|
|
1206
1225
|
errors << "#{e}"
|
|
1207
1226
|
end
|
|
1208
1227
|
|
|
1209
|
-
|
|
1210
|
-
type, opts = network
|
|
1211
|
-
|
|
1212
|
-
if opts[:mac]
|
|
1213
|
-
if opts[:mac] =~ /\A([0-9a-fA-F]{12})\z/
|
|
1214
|
-
opts[:mac] = opts[:mac].scan(/../).join(':')
|
|
1215
|
-
end
|
|
1216
|
-
unless opts[:mac] =~ /\A([0-9a-fA-F]{2}:){5}([0-9a-fA-F]{2})\z/
|
|
1217
|
-
errors << "Configured NIC MAC '#{opts[:mac]}' is not in 'xx:xx:xx:xx:xx:xx' or 'xxxxxxxxxxxx' format"
|
|
1218
|
-
end
|
|
1219
|
-
end
|
|
1220
|
-
|
|
1221
|
-
# only interested in public networks where portgroup is nil, as then source will be a host device
|
|
1222
|
-
if type == :public_network && opts[:portgroup] == nil
|
|
1223
|
-
devices = host_devices(machine)
|
|
1224
|
-
hostdev = opts.fetch(:dev, 'eth0')
|
|
1225
|
-
if !devices.include?(hostdev)
|
|
1226
|
-
errors << "network configuration #{index} for machine #{machine.name} is a public_network referencing host device '#{hostdev}' which does not exist, consider adding ':dev => ....' referencing one of #{devices.join(", ")}"
|
|
1227
|
-
end
|
|
1228
|
-
end
|
|
1229
|
-
end
|
|
1228
|
+
errors = validate_networks(machine, errors)
|
|
1230
1229
|
|
|
1231
1230
|
if !machine.provider_config.volume_cache.nil? and machine.provider_config.volume_cache != UNSET_VALUE
|
|
1232
1231
|
machine.ui.warn("Libvirt Provider: volume_cache is deprecated. Use disk_driver :cache => '#{machine.provider_config.volume_cache}' instead.")
|
|
@@ -1250,6 +1249,10 @@ module VagrantPlugins
|
|
|
1250
1249
|
end
|
|
1251
1250
|
end
|
|
1252
1251
|
|
|
1252
|
+
if [@clock_absolute, @clock_adjustment, @clock_timezone].count {|clock| !clock.nil?} > 1
|
|
1253
|
+
errors << "At most, only one of [clock_absolute, clock_adjustment, clock_timezone] may be set."
|
|
1254
|
+
end
|
|
1255
|
+
|
|
1253
1256
|
errors = validate_sysinfo(machine, errors)
|
|
1254
1257
|
|
|
1255
1258
|
{ 'Libvirt Provider' => errors }
|
|
@@ -1320,8 +1323,8 @@ module VagrantPlugins
|
|
|
1320
1323
|
end
|
|
1321
1324
|
end
|
|
1322
1325
|
|
|
1323
|
-
# Extract host values from uri if provided, otherwise
|
|
1324
|
-
@host = uri.host
|
|
1326
|
+
# Extract host values from uri if provided, otherwise set empty string
|
|
1327
|
+
@host = uri.host || ""
|
|
1325
1328
|
@port = uri.port
|
|
1326
1329
|
# only override username if there is a value provided
|
|
1327
1330
|
@username = nil if @username == UNSET_VALUE
|
|
@@ -1389,11 +1392,55 @@ module VagrantPlugins
|
|
|
1389
1392
|
end
|
|
1390
1393
|
end
|
|
1391
1394
|
|
|
1392
|
-
def
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1395
|
+
def validate_networks(machine, errors)
|
|
1396
|
+
begin
|
|
1397
|
+
networks = configured_networks(machine, @logger)
|
|
1398
|
+
rescue Errors::VagrantLibvirtError => e
|
|
1399
|
+
errors << "#{e}"
|
|
1400
|
+
|
|
1401
|
+
return
|
|
1396
1402
|
end
|
|
1403
|
+
|
|
1404
|
+
return if networks.empty?
|
|
1405
|
+
|
|
1406
|
+
networks.each_with_index do |network, index|
|
|
1407
|
+
if network[:mac]
|
|
1408
|
+
if network[:mac] =~ /\A([0-9a-fA-F]{12})\z/
|
|
1409
|
+
network[:mac] = network[:mac].scan(/../).join(':')
|
|
1410
|
+
end
|
|
1411
|
+
unless network[:mac] =~ /\A([0-9a-fA-F]{2}:){5}([0-9a-fA-F]{2})\z/
|
|
1412
|
+
errors << "Configured NIC MAC '#{network[:mac]}' is not in 'xx:xx:xx:xx:xx:xx' or 'xxxxxxxxxxxx' format"
|
|
1413
|
+
end
|
|
1414
|
+
end
|
|
1415
|
+
|
|
1416
|
+
# only interested in public networks where portgroup is nil, as then source will be a host device
|
|
1417
|
+
if network[:iface_type] == :public_network && network[:portgroup] == nil
|
|
1418
|
+
exclude_prefixes = @host_device_exclude_prefixes
|
|
1419
|
+
# for qemu sessions the management network injected will be a public_network trying to use a libvirt managed device
|
|
1420
|
+
if index == 0 and machine.provider_config.mgmt_attach and machine.provider_config.qemu_use_session == true
|
|
1421
|
+
exclude_prefixes.delete('virbr')
|
|
1422
|
+
end
|
|
1423
|
+
|
|
1424
|
+
devices = machine.provider.driver.host_devices.select do |dev|
|
|
1425
|
+
next if dev.empty?
|
|
1426
|
+
dev != "lo" && !exclude_prefixes.any? { |exclude| dev.start_with?(exclude) }
|
|
1427
|
+
end
|
|
1428
|
+
hostdev = network.fetch(:dev, 'eth0')
|
|
1429
|
+
|
|
1430
|
+
if !devices.include?(hostdev)
|
|
1431
|
+
errors << "network configuration #{index} for machine #{machine.name} is a public_network referencing host device '#{hostdev}' which does not exist, consider adding ':dev => ....' referencing one of #{devices.join(", ")}"
|
|
1432
|
+
end
|
|
1433
|
+
end
|
|
1434
|
+
|
|
1435
|
+
unless network[:iface_name].nil?
|
|
1436
|
+
restricted_devnames = ['vnet', 'vif', 'macvtap', 'macvlan']
|
|
1437
|
+
if restricted_devnames.any? { |restricted| network[:iface_name].start_with?(restricted) }
|
|
1438
|
+
errors << "network configuration for machine #{machine.name} with setting :libvirt__iface_name => '#{network[:iface_name]}' starts with a restricted prefix according to libvirt docs https://libvirt.org/formatdomain.html#overriding-the-target-element, please use a device name that does not start with one of #{restricted_devnames.join(", ")}"
|
|
1439
|
+
end
|
|
1440
|
+
end
|
|
1441
|
+
end
|
|
1442
|
+
|
|
1443
|
+
errors
|
|
1397
1444
|
end
|
|
1398
1445
|
|
|
1399
1446
|
def validate_sysinfo(machine, errors)
|
|
@@ -132,7 +132,15 @@
|
|
|
132
132
|
</hyperv>
|
|
133
133
|
<%- end -%>
|
|
134
134
|
</features>
|
|
135
|
+
<%- if not @clock_absolute.nil? -%>
|
|
136
|
+
<clock offset='absolute' start='<%= @clock_absolute %>'>
|
|
137
|
+
<%- elsif not @clock_adjustment.nil? -%>
|
|
138
|
+
<clock offset='variable' basis='<%= @clock_basis %>' adjustment='<%= @clock_adjustment %>'>
|
|
139
|
+
<%- elsif not @clock_timezone.nil? -%>
|
|
140
|
+
<clock offset='timezone' timezone='<%= @clock_timezone %>'>
|
|
141
|
+
<%- else -%>
|
|
135
142
|
<clock offset='<%= @clock_offset %>'>
|
|
143
|
+
<%- end -%>
|
|
136
144
|
<%- @clock_timers.each do |clock_timer| -%>
|
|
137
145
|
<timer<% clock_timer.each do |attr, value| %> <%= attr %>='<%= value %>'<% end %>/>
|
|
138
146
|
<%- end -%>
|
|
@@ -144,11 +152,11 @@
|
|
|
144
152
|
<%- @domain_volumes.each_with_index do |volume, index| -%>
|
|
145
153
|
<disk type='file' device='disk'>
|
|
146
154
|
<alias name='ua-box-volume-<%= index -%>'/>
|
|
147
|
-
<driver name='qemu'
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
155
|
+
<driver name='qemu' <%=
|
|
156
|
+
{:type => 'qcow2', :cache => "#{volume[:cache]}"}.merge(@disk_driver_opts)
|
|
157
|
+
.reject { |k,v| v.nil? }
|
|
158
|
+
.map { |k,v| "#{k}='#{v}'"}
|
|
159
|
+
.join(' ') -%>/>
|
|
152
160
|
<source file='<%= volume[:absolute_path] %>'/>
|
|
153
161
|
<%# we need to ensure a unique target dev -%>
|
|
154
162
|
<target dev='<%= volume[:device] %>' bus='<%= volume[:bus] %>'/>
|
|
@@ -167,12 +175,12 @@
|
|
|
167
175
|
<%- @disks.each_with_index do |d, index| -%>
|
|
168
176
|
<disk type='file' device='disk'>
|
|
169
177
|
<alias name='ua-disk-volume-<%= index -%>'/>
|
|
170
|
-
<driver name='qemu'
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
178
|
+
<driver name='qemu' <%=
|
|
179
|
+
{:type => 'qcow2'}.merge(d)
|
|
180
|
+
.select { |k,_| [:type, :cache, :io, :copy_on_read, :discard, :detect_zeroes].include? k }
|
|
181
|
+
.reject { |k,v| v.nil? }
|
|
182
|
+
.map { |k,v| "#{k}='#{v}'"}
|
|
183
|
+
.join(' ') -%>/>
|
|
176
184
|
<source file='<%= d[:absolute_path] %>'/>
|
|
177
185
|
<target dev='<%= d[:device] %>' bus='<%= d[:bus] %>'/>
|
|
178
186
|
<%- if d[:address_type] || @disk_address_type -%>
|
|
@@ -208,9 +216,12 @@
|
|
|
208
216
|
<%- end -%>
|
|
209
217
|
<%- @serials.each_with_index do |serial, port| -%>
|
|
210
218
|
<serial type='<%= serial[:type] %>'>
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
219
|
+
<%- unless serial[:source].nil?
|
|
220
|
+
source = serial[:source]
|
|
221
|
+
seclabel = serial[:source][:seclabel]
|
|
222
|
+
-%>
|
|
223
|
+
<source path='<%= source[:path] %>' append='<%= source.fetch(:append, 'on') %>'/>
|
|
224
|
+
<%- end -%>
|
|
214
225
|
<target port='<%= port %>'/>
|
|
215
226
|
</serial>
|
|
216
227
|
<%- end -%>
|
|
@@ -1,34 +1,39 @@
|
|
|
1
1
|
<interface type='<%= @type %>'<% if @trust_guest_rx_filters %> trustGuestRxFilters='yes'<% end %>>
|
|
2
2
|
<alias name='ua-net-<%= @iface_number %>'/>
|
|
3
|
-
|
|
3
|
+
<%- if @mac %>
|
|
4
4
|
<mac address='<%= @mac %>'/>
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
<%- end %>
|
|
6
|
+
<%- if @type == 'direct'%>
|
|
7
7
|
<source dev='<%= @device %>' mode='<%= @mode %>'/>
|
|
8
|
-
|
|
8
|
+
<%- elsif !@portgroup.nil? %>
|
|
9
9
|
<source network='<%=@network_name%>' portgroup='<%=@portgroup%>'/>
|
|
10
|
-
|
|
10
|
+
<%- else %>
|
|
11
11
|
<source bridge='<%=@device%>'/>
|
|
12
|
-
|
|
12
|
+
<%- end %>
|
|
13
|
+
<%- unless @device_name.nil? %>
|
|
14
|
+
<target dev='<%= @device_name %>'/>
|
|
15
|
+
<%- end %>
|
|
13
16
|
<model type='<%=@model_type%>'/>
|
|
14
|
-
|
|
17
|
+
<%- if @driver_name and @driver_queues %>
|
|
15
18
|
<driver <% if @driver_iommu %> iommu="on" <% end %> name='<%=@driver_name%>' queues='<%=@driver_queues%>'/>
|
|
16
|
-
|
|
19
|
+
<%- elsif @driver_queues %>
|
|
17
20
|
<driver <% if @driver_iommu %> iommu="on" <% end %> queues='<%=@driver_queues%>'/>
|
|
18
|
-
|
|
21
|
+
<%- elsif @driver_name %>
|
|
19
22
|
<driver <% if @driver_iommu %> iommu="on" <% end %> name='<%=@driver_name%>'/>
|
|
20
|
-
|
|
23
|
+
<%- elsif @driver_iommu %>
|
|
21
24
|
<driver iommu='on' />
|
|
25
|
+
<%- end %>
|
|
26
|
+
<% if @mtu %>
|
|
27
|
+
<mtu size="<%= @mtu %>" />
|
|
22
28
|
<% end %>
|
|
23
|
-
|
|
24
|
-
<% if @ovs %>
|
|
29
|
+
<%- if @ovs %>
|
|
25
30
|
<virtualport type='openvswitch'>
|
|
26
|
-
|
|
31
|
+
<%- if @ovs_interfaceid %>
|
|
27
32
|
<parameters interfaceid='<%=@ovs_interfaceid%>'/>
|
|
28
|
-
|
|
33
|
+
<%- end %>
|
|
29
34
|
</virtualport>
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
<%- end %>
|
|
36
|
+
<%- if @pci_bus and @pci_slot %>
|
|
32
37
|
<address type='pci' bus='<%=@pci_bus%>' slot='<%=@pci_slot%>' />
|
|
33
|
-
|
|
38
|
+
<%- end %>
|
|
34
39
|
</interface>
|